summaryrefslogtreecommitdiff
path: root/toxcore
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore')
-rw-r--r--toxcore/DHT.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/toxcore/DHT.c b/toxcore/DHT.c
index a2d0b5d8..51dd60f2 100644
--- a/toxcore/DHT.c
+++ b/toxcore/DHT.c
@@ -199,7 +199,7 @@ static void get_close_nodes_inner(DHT *dht, uint8_t *client_id, Node_format *nod
199 sa_family_t sa_family, Client_data *client_list, uint32_t client_list_length, 199 sa_family_t sa_family, Client_data *client_list, uint32_t client_list_length,
200 time_t timestamp, int *num_nodes_ptr) 200 time_t timestamp, int *num_nodes_ptr)
201{ 201{
202 int num_nodes = 0; 202 int num_nodes = *num_nodes_ptr;
203 int i, tout, inlist, ipv46x, j, closest; 203 int i, tout, inlist, ipv46x, j, closest;
204 204
205 for (i = 0; i < client_list_length; i++) { 205 for (i = 0; i < client_list_length; i++) {
@@ -459,7 +459,7 @@ static int is_gettingnodes(DHT *dht, IP_Port ip_port, uint64_t ping_id)
459 if (ip_isset(&ip_port.ip) && ipport_equal(&dht->send_nodes[i].ip_port, &ip_port)) 459 if (ip_isset(&ip_port.ip) && ipport_equal(&dht->send_nodes[i].ip_port, &ip_port))
460 ++pinging; 460 ++pinging;
461 461
462 if (pinging == (ping_id != 0) + (ip_isset(&ip_port.ip) != 0)) 462 if (pinging == (ping_id != 0) + ip_isset(&ip_port.ip))
463 return 1; 463 return 1;
464 } 464 }
465 } 465 }
@@ -679,7 +679,8 @@ static int handle_getnodes(void *object, IP_Port source, uint8_t *packet, uint32
679 memcpy(&ping_id, plain, sizeof(ping_id)); 679 memcpy(&ping_id, plain, sizeof(ping_id));
680 sendnodes(dht, source, packet + 1, plain + sizeof(ping_id), ping_id); 680 sendnodes(dht, source, packet + 1, plain + sizeof(ping_id), ping_id);
681#ifdef TOX_ENABLE_IPV6 681#ifdef TOX_ENABLE_IPV6
682 sendnodes_ipv6(dht, source, packet + 1, plain + sizeof(ping_id), ping_id); 682 sendnodes_ipv6(dht, source, packet + 1, plain + sizeof(ping_id),
683 ping_id); /* TODO: prevent possible amplification attacks */
683#endif 684#endif
684 685
685 //send_ping_request(dht, source, packet + 1); /* TODO: make this smarter? */ 686 //send_ping_request(dht, source, packet + 1); /* TODO: make this smarter? */
@@ -764,7 +765,7 @@ static int handle_sendnodes_ipv6(void *object, IP_Port source, uint8_t *packet,
764 uint32_t cid_size = 1 + CLIENT_ID_SIZE; 765 uint32_t cid_size = 1 + CLIENT_ID_SIZE;
765 cid_size += crypto_box_NONCEBYTES + sizeof(ping_id) + ENCRYPTION_PADDING; 766 cid_size += crypto_box_NONCEBYTES + sizeof(ping_id) + ENCRYPTION_PADDING;
766 767
767 size_t Node_format_size = sizeof(Node4_format); 768 size_t Node_format_size = sizeof(Node_format);
768 769
769 if (length > (cid_size + Node_format_size * MAX_SENT_NODES) || 770 if (length > (cid_size + Node_format_size * MAX_SENT_NODES) ||
770 ((length - cid_size) % Node_format_size) != 0 || 771 ((length - cid_size) % Node_format_size) != 0 ||