-fix message types for namestore, eliminate conflict with LM
[oweals/gnunet.git] / src / namestore / plugin_namestore_sqlite.c
index 45fad545cddc547b3cd1ba0fea05c6e75d524b10..8b35fb84c69d166a79441211919e236febd97527 100644 (file)
@@ -27,6 +27,7 @@
 #include "platform.h"
 #include "gnunet_namestore_plugin.h"
 #include "gnunet_namestore_service.h"
+#include "namestore.h"
 #include <sqlite3.h>
 
 /**
@@ -590,6 +591,13 @@ get_record_and_call_iterator (struct Plugin *plugin,
       GNUNET_break (0);
       ret = GNUNET_SYSERR;
     }
+    else if (record_count > 64 * 1024)
+    {
+      /* sanity check, don't stack allocate far too much just
+        because database might contain a large value here */
+      GNUNET_break (0);
+      ret = GNUNET_SYSERR;
+    } 
     else
     {
       struct GNUNET_NAMESTORE_RecordData rd[record_count];
@@ -600,7 +608,6 @@ get_record_and_call_iterator (struct Plugin *plugin,
       {
        GNUNET_break (0);
        ret = GNUNET_SYSERR;
-       record_count = 0;
       }
       else
       {
@@ -745,7 +752,6 @@ namestore_sqlite_zone_to_name (void *cls,
                  "sqlite3_reset");
     return GNUNET_SYSERR;
   }      
-
   return get_record_and_call_iterator (plugin, stmt, iter, iter_cls);
 }