From: Christian Grothoff Date: Sun, 22 Jan 2017 22:53:27 +0000 (+0100) Subject: do not send malformed payload in test X-Git-Tag: taler-0.2.1~347 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=4812be40692ea16b71ba15d6703ea1ef524dffa1;p=oweals%2Fgnunet.git do not send malformed payload in test --- 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) * @param size Size of the buffer we have. * @param buf Buffer to copy data to. */ -size_t +static size_t tmt_rdy (void *cls, size_t size, void *buf) { struct GNUNET_MessageHeader *msg = buf; @@ -547,6 +547,7 @@ tmt_rdy (void *cls, size_t size, void *buf) GNUNET_assert (0); counter = get_expected_target () == id ? ack_sent : data_sent; msg_size = size_payload + counter; + GNUNET_assert (msg_size > sizeof (struct GNUNET_MessageHeader)); if ( (size < msg_size) || (NULL == buf) ) { @@ -567,9 +568,11 @@ tmt_rdy (void *cls, size_t size, void *buf) *data = htonl (counter); if (GNUNET_NO == initialized) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending initializer\n"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "sending initializer\n"); msg_size = size_payload + 1000; - if (SPEED_ACK == test) + msg->size = htons (msg_size); + if (SPEED_ACK == test) data_sent++; } else if ( (SPEED == test) || @@ -601,7 +604,7 @@ tmt_rdy (void *cls, size_t size, void *buf) /** * Function is called whenever a message is received. * - * @param cls closure (set from GNUNET_CADET_connect, peer number) + * @param cls closure (set from GNUNET_CADET_connect(), peer number) * @param channel connection to the other end * @param channel_ctx place to store local state associated with the channel * @param message the actual message