fix
authorChristian Grothoff <christian@grothoff.org>
Wed, 27 Jul 2011 07:40:39 +0000 (07:40 +0000)
committerChristian Grothoff <christian@grothoff.org>
Wed, 27 Jul 2011 07:40:39 +0000 (07:40 +0000)
src/fragmentation/defragmentation.c
src/fragmentation/fragmentation.c
src/fragmentation/test_fragmentation.c

index 29d2c3c424d49ac58a4de7fc99ac51aa59a691b0..8aad86003c2a2cf5d91d8b53c2e80ad91733da96 100644 (file)
@@ -18,7 +18,7 @@
      Boston, MA 02111-1307, USA.
 */
 /**
- * @file src/fragmentation/defragmentation_new.c
+ * @file src/fragmentation/defragmentation.c
  * @brief library to help defragment messages
  * @author Christian Grothoff
  */
@@ -441,6 +441,11 @@ GNUNET_DEFRAGMENT_process_fragment (struct GNUNET_DEFRAGMENT_Context *dc,
     }
   fh = (const struct FragmentHeader*) msg;
   msize = ntohs (fh->total_size);
+  if (msize < sizeof (struct GNUNET_MessageHeader))
+    {
+      GNUNET_break_op (0);
+      return GNUNET_SYSERR;
+    }
   fid = ntohl (fh->fragment_id);
   foff = ntohs (fh->offset);
   if (foff >= msize)
@@ -554,5 +559,5 @@ GNUNET_DEFRAGMENT_process_fragment (struct GNUNET_DEFRAGMENT_Context *dc,
   return GNUNET_YES;
 }
 
-/* end of defragmentation_new.c */
+/* end of defragmentation.c */
 
index 77b4c2e495cafb4287ec3af4d25420435b04141c..e97b0f76303cdc4dab9318e2e1cd94c50b05a895 100644 (file)
@@ -18,7 +18,7 @@
      Boston, MA 02111-1307, USA.
 */
 /**
- * @file src/fragmentation/fragmentation_new.c
+ * @file src/fragmentation/fragmentation.c
  * @brief library to help fragment messages
  * @author Christian Grothoff
  */
@@ -249,11 +249,11 @@ GNUNET_FRAGMENT_context_create (struct GNUNET_STATISTICS_Handle *stats,
                            _("# messages fragmented"),
                            1, GNUNET_NO);
   GNUNET_assert (mtu >= 1024 + sizeof (struct FragmentHeader));
-  size = ntohs (msg->size);
+  size = ntohs (msg->size); 
   GNUNET_STATISTICS_update (stats,
                            _("# total size of fragmented messages"),
                            size, GNUNET_NO);
-  //GNUNET_assert (size > mtu);
+  GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader));
   fc = GNUNET_malloc (sizeof (struct GNUNET_FRAGMENT_Context) + size);
   fc->stats = stats;
   fc->mtu = mtu;
@@ -398,5 +398,5 @@ GNUNET_FRAGMENT_context_destroy (struct GNUNET_FRAGMENT_Context *fc)
 }
 
 
-/* end of fragmentation_new.c */
+/* end of fragmentation.c */
 
index 4415664a4aca3e2cb9ce0f6b3eb5b08617bea749..25f1c2053f76d16f7da8a88ac5f11b6d9b642e17 100644 (file)
@@ -208,7 +208,7 @@ run (void *cls,
   for (i=0;i<NUM_MSGS;i++)
     {
       msg->type = htons ((uint16_t) i);
-      msg->size = htons ( 1 + (17 * i) % (32 * 1024));
+      msg->size = htons (sizeof (struct GNUNET_MessageHeader) + (17 * i) % (32 * 1024));
       frags[i] = GNUNET_FRAGMENT_context_create (NULL /* no stats */, 
                                                 MTU,
                                                 &trackers[i],