X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ffreenet%2Fintroductionpuzzlerequester.cpp;h=70b3102fe01099469110c86b4880f5794cf0872e;hb=9b22dd53fe62e312c1647310b7ec43aa127090af;hp=1a24bd02b9d41b3dd71b8fd0d20d3cf62c379441;hpb=ee580d19b7920904587e18d72a3465d52eab6204;p=fms.git diff --git a/src/freenet/introductionpuzzlerequester.cpp b/src/freenet/introductionpuzzlerequester.cpp index 1a24bd0..70b3102 100644 --- a/src/freenet/introductionpuzzlerequester.cpp +++ b/src/freenet/introductionpuzzlerequester.cpp @@ -2,6 +2,8 @@ #include "../../include/freenet/introductionpuzzlexml.h" #include "../../include/option.h" #include "../../include/stringfunctions.h" +#include "../../include/bitmapvalidator.h" +#include "../../include/base64.h" #ifdef XMEM #include @@ -104,6 +106,16 @@ const bool IntroductionPuzzleRequester::HandleAllData(FCPMessage &message) validmessage=false; } + // we can only validate bitmaps for now + BitmapValidator val; + std::vector puzzledata; + Base64::Decode(xml.GetPuzzleData(),puzzledata); + if(xml.GetMimeType()!="image/bmp" || val.Validate(puzzledata)==false) + { + m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"IntroductionPuzzleRequester::HandleAllData received bad mime type and/or data for "+message["Identifier"]); + validmessage=false; + } + st=m_db->Prepare("INSERT INTO tblIntroductionPuzzleRequests(IdentityID,Day,RequestIndex,Found,UUID,Type,MimeType,PuzzleData) VALUES(?,?,?,?,?,?,?,?);"); st.Bind(0,identityid); st.Bind(1,idparts[4]); @@ -252,8 +264,8 @@ void IntroductionPuzzleRequester::PopulateIDList() now.SetToGMTime(); - // select identities that aren't single use and have been seen today ( order by trust DESC and limit to limitnum ) - st=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublicKey IS NOT NULL AND PublicKey <> '' AND SingleUse='false' AND LastSeen>='"+now.Format("%Y-%m-%d")+"' ORDER BY LocalMessageTrust DESC LIMIT 0,"+limitnum+";"); + // 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>='"+now.Format("%Y-%m-%d")+"' ORDER BY LocalMessageTrust DESC LIMIT 0,"+limitnum+";"); st.Step(); m_ids.clear();