-fix, handle case where there is no update
[oweals/gnunet.git] / src / fs / gnunet-helper-fs-publish.c
index d429f603db1efa7648a71625d84b5f09fde93c3a..7ea94998d2b746580ee93609d049da45750310ac 100644 (file)
@@ -377,6 +377,11 @@ extract_files (struct ScanTreeNode *item)
       return GNUNET_SYSERR;    
     return GNUNET_OK;
   }
+  else if (size > (UINT16_MAX - sizeof (struct GNUNET_MessageHeader) - slen))
+  {
+    /* We can't transfer more than 64k bytes in one message. */
+    size = UINT16_MAX - sizeof (struct GNUNET_MessageHeader) - slen;
+  }
   {
     char buf[size + slen];
     char *dst = &buf[slen];
@@ -461,7 +466,9 @@ int main(int argc,
     FPRINTF (stderr, 
             "%s",
             "gnunet-helper-fs-publish needs exactly one or two arguments\n");
+#if WINDOWS
     GNUNET_free ((void*) argv);
+#endif
     return 1;
   }
   filename_expanded = argv[1];
@@ -481,7 +488,9 @@ int main(int argc,
   {
     (void) write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_ERROR, NULL, 0);
     EXTRACTOR_plugin_remove_all (plugins);
+#if WINDOWS
     GNUNET_free ((void*) argv);
+#endif
     return 2;
   }
   /* signal that we're done counting files, so that a percentage of 
@@ -490,7 +499,9 @@ int main(int argc,
       write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_COUNTING_DONE, NULL, 0))
   {
     EXTRACTOR_plugin_remove_all (plugins);
+#if WINDOWS
     GNUNET_free ((void*) argv);
+#endif
     return 3;  
   }
   if (NULL != root)
@@ -501,7 +512,9 @@ int main(int argc,
       (void) write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_ERROR, NULL, 0);
       free_tree (root);
       EXTRACTOR_plugin_remove_all (plugins);
+#if WINDOWS
       GNUNET_free ((void*) argv);
+#endif
       return 4;
     }
     free_tree (root);
@@ -509,7 +522,9 @@ int main(int argc,
   /* enable "clean" shutdown by telling parent that we are done */
   (void) write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_FINISHED, NULL, 0);
   EXTRACTOR_plugin_remove_all (plugins);
+#if WINDOWS
   GNUNET_free ((void*) argv);  
+#endif
   return 0;
 }