version 0.2.23
[fms.git] / src / freenet / introductionpuzzlerequester.cpp
index 1a24bd0..70b3102 100644 (file)
@@ -2,6 +2,8 @@
 #include "../../include/freenet/introductionpuzzlexml.h"\r
 #include "../../include/option.h"\r
 #include "../../include/stringfunctions.h"\r
+#include "../../include/bitmapvalidator.h"\r
+#include "../../include/base64.h"\r
 \r
 #ifdef XMEM\r
        #include <xmem.h>\r
@@ -104,6 +106,16 @@ const bool IntroductionPuzzleRequester::HandleAllData(FCPMessage &message)
                        validmessage=false;\r
                }\r
 \r
+               // we can only validate bitmaps for now\r
+               BitmapValidator val;\r
+               std::vector<unsigned char> puzzledata;\r
+               Base64::Decode(xml.GetPuzzleData(),puzzledata);\r
+               if(xml.GetMimeType()!="image/bmp" || val.Validate(puzzledata)==false)\r
+               {\r
+                       m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"IntroductionPuzzleRequester::HandleAllData received bad mime type and/or data for "+message["Identifier"]);\r
+                       validmessage=false;\r
+               }\r
+\r
                st=m_db->Prepare("INSERT INTO tblIntroductionPuzzleRequests(IdentityID,Day,RequestIndex,Found,UUID,Type,MimeType,PuzzleData) VALUES(?,?,?,?,?,?,?,?);");\r
                st.Bind(0,identityid);\r
                st.Bind(1,idparts[4]);\r
@@ -252,8 +264,8 @@ void IntroductionPuzzleRequester::PopulateIDList()
 \r
        now.SetToGMTime();\r
 \r
-       // select identities that aren't single use and have been seen today ( order by trust DESC and limit to limitnum )\r
-       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+";");\r
+       // 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 )\r
+       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+";");\r
        st.Step();\r
 \r
        m_ids.clear();\r