aboutsummaryrefslogtreecommitdiff
path: root/src/cadet/test_cadet.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-01-22 23:53:27 +0100
committerChristian Grothoff <christian@grothoff.org>2017-01-22 23:53:27 +0100
commit4812be40692ea16b71ba15d6703ea1ef524dffa1 (patch)
tree19597a8554b19bd8d1055ccaff395ae9bf7d5286 /src/cadet/test_cadet.c
parent22141e7eb07d6331ad1c2548032c2de014f33383 (diff)
downloadgnunet-4812be40692ea16b71ba15d6703ea1ef524dffa1.tar.gz
gnunet-4812be40692ea16b71ba15d6703ea1ef524dffa1.zip
do not send malformed payload in test
Diffstat (limited to 'src/cadet/test_cadet.c')
-rw-r--r--src/cadet/test_cadet.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/cadet/test_cadet.c b/src/cadet/test_cadet.c
index b19963bba..16466ca0d 100644
--- a/src/cadet/test_cadet.c
+++ b/src/cadet/test_cadet.c
@@ -527,7 +527,7 @@ data_task (void *cls)
527 * @param size Size of the buffer we have. 527 * @param size Size of the buffer we have.
528 * @param buf Buffer to copy data to. 528 * @param buf Buffer to copy data to.
529 */ 529 */
530size_t 530static size_t
531tmt_rdy (void *cls, size_t size, void *buf) 531tmt_rdy (void *cls, size_t size, void *buf)
532{ 532{
533 struct GNUNET_MessageHeader *msg = buf; 533 struct GNUNET_MessageHeader *msg = buf;
@@ -547,6 +547,7 @@ tmt_rdy (void *cls, size_t size, void *buf)
547 GNUNET_assert (0); 547 GNUNET_assert (0);
548 counter = get_expected_target () == id ? ack_sent : data_sent; 548 counter = get_expected_target () == id ? ack_sent : data_sent;
549 msg_size = size_payload + counter; 549 msg_size = size_payload + counter;
550 GNUNET_assert (msg_size > sizeof (struct GNUNET_MessageHeader));
550 if ( (size < msg_size) || 551 if ( (size < msg_size) ||
551 (NULL == buf) ) 552 (NULL == buf) )
552 { 553 {
@@ -567,9 +568,11 @@ tmt_rdy (void *cls, size_t size, void *buf)
567 *data = htonl (counter); 568 *data = htonl (counter);
568 if (GNUNET_NO == initialized) 569 if (GNUNET_NO == initialized)
569 { 570 {
570 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending initializer\n"); 571 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
572 "sending initializer\n");
571 msg_size = size_payload + 1000; 573 msg_size = size_payload + 1000;
572 if (SPEED_ACK == test) 574 msg->size = htons (msg_size);
575 if (SPEED_ACK == test)
573 data_sent++; 576 data_sent++;
574 } 577 }
575 else if ( (SPEED == test) || 578 else if ( (SPEED == test) ||
@@ -601,7 +604,7 @@ tmt_rdy (void *cls, size_t size, void *buf)
601/** 604/**
602 * Function is called whenever a message is received. 605 * Function is called whenever a message is received.
603 * 606 *
604 * @param cls closure (set from GNUNET_CADET_connect, peer number) 607 * @param cls closure (set from GNUNET_CADET_connect(), peer number)
605 * @param channel connection to the other end 608 * @param channel connection to the other end
606 * @param channel_ctx place to store local state associated with the channel 609 * @param channel_ctx place to store local state associated with the channel
607 * @param message the actual message 610 * @param message the actual message