Fixed regression, announce responses can contain 0 nodes.

This commit is contained in:
irungentoo 2014-04-15 19:16:35 -04:00
parent f9bf7b074a
commit be413de396
No known key found for this signature in database
GPG Key ID: 10349DC9BED89E98
2 changed files with 8 additions and 3 deletions

View File

@ -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));

View File

@ -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,