Skip to content

Commit

Permalink
Fixed regression, announce responses can contain 0 nodes.
Browse files Browse the repository at this point in the history
  • Loading branch information
irungentoo committed Apr 15, 2014
1 parent f9bf7b0 commit be413de
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions auto_tests/onion_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
10 changes: 7 additions & 3 deletions toxcore/onion_announce.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit be413de

Please sign in to comment.