X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ffreenet%2Fintroductionpuzzlerequester.cpp;h=88fd48307e2fd4dd2d3bd86edc78d0611f526f85;hb=c0ebc7b53a977885ebc2d3a679c586ae20c0bc4a;hp=f7d53174354ee0b7ad30b0765aacf8b162a10553;hpb=dec33c63afafabf83c3039e916725cac6faef9b3;p=fms.git diff --git a/src/freenet/introductionpuzzlerequester.cpp b/src/freenet/introductionpuzzlerequester.cpp index f7d5317..88fd483 100644 --- a/src/freenet/introductionpuzzlerequester.cpp +++ b/src/freenet/introductionpuzzlerequester.cpp @@ -66,10 +66,13 @@ const bool IntroductionPuzzleRequester::HandleAllData(FCPMessage &message) // receive the file data.resize(datalength); - m_fcp->ReceiveRaw(&data[0],datalength); + if(data.size()>0) + { + m_fcp->ReceiveRaw(&data[0],datalength); + } // parse file into xml and update the database - if(xml.ParseXML(std::string(data.begin(),data.end()))==true) + if(data.size()>0 && xml.ParseXML(std::string(data.begin(),data.end()))==true) { // check if last part of UUID matches first part of public key of identity who inserted it @@ -112,6 +115,7 @@ const bool IntroductionPuzzleRequester::HandleAllData(FCPMessage &message) // we can only validate bitmaps for now BitmapValidator val; + val.SetMax(200,200); std::vector puzzledata; Base64::Decode(xml.GetPuzzleData(),puzzledata); if(xml.GetMimeType()!="image/bmp" || val.Validate(puzzledata)==false) @@ -233,17 +237,16 @@ const bool IntroductionPuzzleRequester::HandleMessage(FCPMessage &message) void IntroductionPuzzleRequester::Initialize() { - std::string tempval=""; - Option::Instance()->Get("MaxIntroductionPuzzleRequests",tempval); - StringFunctions::Convert(tempval,m_maxrequests); + m_maxrequests=0; + Option::Instance()->GetInt("MaxIntroductionPuzzleRequests",m_maxrequests); if(m_maxrequests<1) { m_maxrequests=1; - m_log->error("Option MaxIntroductionPuzzleRequests is currently set at "+tempval+". It must be 1 or greater."); + m_log->error("Option MaxIntroductionPuzzleRequests is currently set at less than 1. It must be 1 or greater."); } if(m_maxrequests>100) { - m_log->warning("Option MaxIntroductionPuzzleRequests is currently set at "+tempval+". This value might be incorrectly configured."); + m_log->warning("Option MaxIntroductionPuzzleRequests is currently set at more than 100. This value might be incorrectly configured."); } Option::Instance()->Get("MessageBase",m_messagebase); m_tempdate=Poco::Timestamp(); @@ -265,7 +268,7 @@ void IntroductionPuzzleRequester::PopulateIDList() st.Finalize(); // select identities that aren't single use, are publishing a trust list, and have been seen today ( order by trust DESC and limit to limitnum ) - st=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublishTrustList='true' AND PublicKey IS NOT NULL AND PublicKey <> '' AND SingleUse='false' AND LastSeen>='"+Poco::DateTimeFormatter::format(now,"%Y-%m-%d")+"' ORDER BY LocalMessageTrust DESC LIMIT 0,"+limitnum+";"); + st=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublishTrustList='true' AND PublicKey IS NOT NULL AND PublicKey <> '' AND SingleUse='false' AND (LocalTrustListTrust IS NULL OR LocalTrustListTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinLocalTrustListTrust')) AND LastSeen>='"+Poco::DateTimeFormatter::format(now,"%Y-%m-%d")+"' ORDER BY LocalMessageTrust DESC LIMIT 0,"+limitnum+";"); st.Step(); m_ids.clear();