diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-07-27 07:40:39 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-07-27 07:40:39 +0000 |
commit | 8d6058c34df98102009ca0a9456da0bcb06d39f2 (patch) | |
tree | e93287bf9a78df33dc454005418548a3b1bee52b /src/fragmentation | |
parent | 22dafb003418aab11e036230b3761116c397d239 (diff) | |
download | gnunet-8d6058c34df98102009ca0a9456da0bcb06d39f2.tar.gz gnunet-8d6058c34df98102009ca0a9456da0bcb06d39f2.zip |
fix
Diffstat (limited to 'src/fragmentation')
-rw-r--r-- | src/fragmentation/defragmentation.c | 9 | ||||
-rw-r--r-- | src/fragmentation/fragmentation.c | 8 | ||||
-rw-r--r-- | src/fragmentation/test_fragmentation.c | 2 |
3 files changed, 12 insertions, 7 deletions
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 @@ | |||
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file src/fragmentation/defragmentation_new.c | 21 | * @file src/fragmentation/defragmentation.c |
22 | * @brief library to help defragment messages | 22 | * @brief library to help defragment messages |
23 | * @author Christian Grothoff | 23 | * @author Christian Grothoff |
24 | */ | 24 | */ |
@@ -441,6 +441,11 @@ GNUNET_DEFRAGMENT_process_fragment (struct GNUNET_DEFRAGMENT_Context *dc, | |||
441 | } | 441 | } |
442 | fh = (const struct FragmentHeader*) msg; | 442 | fh = (const struct FragmentHeader*) msg; |
443 | msize = ntohs (fh->total_size); | 443 | msize = ntohs (fh->total_size); |
444 | if (msize < sizeof (struct GNUNET_MessageHeader)) | ||
445 | { | ||
446 | GNUNET_break_op (0); | ||
447 | return GNUNET_SYSERR; | ||
448 | } | ||
444 | fid = ntohl (fh->fragment_id); | 449 | fid = ntohl (fh->fragment_id); |
445 | foff = ntohs (fh->offset); | 450 | foff = ntohs (fh->offset); |
446 | if (foff >= msize) | 451 | if (foff >= msize) |
@@ -554,5 +559,5 @@ GNUNET_DEFRAGMENT_process_fragment (struct GNUNET_DEFRAGMENT_Context *dc, | |||
554 | return GNUNET_YES; | 559 | return GNUNET_YES; |
555 | } | 560 | } |
556 | 561 | ||
557 | /* end of defragmentation_new.c */ | 562 | /* end of defragmentation.c */ |
558 | 563 | ||
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 @@ | |||
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file src/fragmentation/fragmentation_new.c | 21 | * @file src/fragmentation/fragmentation.c |
22 | * @brief library to help fragment messages | 22 | * @brief library to help fragment messages |
23 | * @author Christian Grothoff | 23 | * @author Christian Grothoff |
24 | */ | 24 | */ |
@@ -249,11 +249,11 @@ GNUNET_FRAGMENT_context_create (struct GNUNET_STATISTICS_Handle *stats, | |||
249 | _("# messages fragmented"), | 249 | _("# messages fragmented"), |
250 | 1, GNUNET_NO); | 250 | 1, GNUNET_NO); |
251 | GNUNET_assert (mtu >= 1024 + sizeof (struct FragmentHeader)); | 251 | GNUNET_assert (mtu >= 1024 + sizeof (struct FragmentHeader)); |
252 | size = ntohs (msg->size); | 252 | size = ntohs (msg->size); |
253 | GNUNET_STATISTICS_update (stats, | 253 | GNUNET_STATISTICS_update (stats, |
254 | _("# total size of fragmented messages"), | 254 | _("# total size of fragmented messages"), |
255 | size, GNUNET_NO); | 255 | size, GNUNET_NO); |
256 | //GNUNET_assert (size > mtu); | 256 | GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader)); |
257 | fc = GNUNET_malloc (sizeof (struct GNUNET_FRAGMENT_Context) + size); | 257 | fc = GNUNET_malloc (sizeof (struct GNUNET_FRAGMENT_Context) + size); |
258 | fc->stats = stats; | 258 | fc->stats = stats; |
259 | fc->mtu = mtu; | 259 | fc->mtu = mtu; |
@@ -398,5 +398,5 @@ GNUNET_FRAGMENT_context_destroy (struct GNUNET_FRAGMENT_Context *fc) | |||
398 | } | 398 | } |
399 | 399 | ||
400 | 400 | ||
401 | /* end of fragmentation_new.c */ | 401 | /* end of fragmentation.c */ |
402 | 402 | ||
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, | |||
208 | for (i=0;i<NUM_MSGS;i++) | 208 | for (i=0;i<NUM_MSGS;i++) |
209 | { | 209 | { |
210 | msg->type = htons ((uint16_t) i); | 210 | msg->type = htons ((uint16_t) i); |
211 | msg->size = htons ( 1 + (17 * i) % (32 * 1024)); | 211 | msg->size = htons (sizeof (struct GNUNET_MessageHeader) + (17 * i) % (32 * 1024)); |
212 | frags[i] = GNUNET_FRAGMENT_context_create (NULL /* no stats */, | 212 | frags[i] = GNUNET_FRAGMENT_context_create (NULL /* no stats */, |
213 | MTU, | 213 | MTU, |
214 | &trackers[i], | 214 | &trackers[i], |