From: Christian Grothoff Date: Wed, 27 Jul 2011 07:40:39 +0000 (+0000) Subject: fix X-Git-Tag: initial-import-from-subversion-38251~17607 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=8d6058c34df98102009ca0a9456da0bcb06d39f2;p=oweals%2Fgnunet.git fix --- diff --git a/src/fragmentation/defragmentation.c b/src/fragmentation/defragmentation.c index 29d2c3c42..8aad86003 100644 --- a/src/fragmentation/defragmentation.c +++ b/src/fragmentation/defragmentation.c @@ -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 */ diff --git a/src/fragmentation/fragmentation.c b/src/fragmentation/fragmentation.c index 77b4c2e49..e97b0f763 100644 --- a/src/fragmentation/fragmentation.c +++ b/src/fragmentation/fragmentation.c @@ -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 */ diff --git a/src/fragmentation/test_fragmentation.c b/src/fragmentation/test_fragmentation.c index 4415664a4..25f1c2053 100644 --- a/src/fragmentation/test_fragmentation.c +++ b/src/fragmentation/test_fragmentation.c @@ -208,7 +208,7 @@ run (void *cls, for (i=0;itype = 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],