From be413de39624c6137e577e3bff14928d2cb873d3 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Tue, 15 Apr 2014 19:16:35 -0400 Subject: [PATCH] Fixed regression, announce responses can contain 0 nodes. --- auto_tests/onion_test.c | 1 + toxcore/onion_announce.c | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/auto_tests/onion_test.c b/auto_tests/onion_test.c index 2f244693..cd060b1f 100644 --- a/auto_tests/onion_test.c +++ b/auto_tests/onion_test.c @@ -186,6 +186,7 @@ START_TEST(test_basic) while (handled_test_3 == 0) { do_onion(onion1); do_onion(onion2); + c_sleep(50); } randombytes(sb_data, sizeof(sb_data)); diff --git a/toxcore/onion_announce.c b/toxcore/onion_announce.c index a1e5495e..7a60a235 100644 --- a/toxcore/onion_announce.c +++ b/toxcore/onion_announce.c @@ -268,10 +268,14 @@ static int handle_announce_request(void *object, IP_Port source, uint8_t *packet } } - int nodes_length = pack_nodes(pl + 1 + ONION_PING_ID_SIZE, sizeof(nodes_list), nodes_list, num_nodes); + int nodes_length = 0; - if (nodes_length <= 0) - return 1; + if (num_nodes != 0) { + nodes_length = pack_nodes(pl + 1 + ONION_PING_ID_SIZE, sizeof(nodes_list), nodes_list, num_nodes); + + if (nodes_length <= 0) + return 1; + } uint8_t data[ONION_ANNOUNCE_RESPONSE_MAX_SIZE]; len = encrypt_data_fast(shared_key, nonce, pl, 1 + ONION_PING_ID_SIZE + nodes_length,