summaryrefslogtreecommitdiff
path: root/toxcore/DHT.c
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/DHT.c')
-rw-r--r--toxcore/DHT.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/toxcore/DHT.c b/toxcore/DHT.c
index 2f7b2263..db9bfe3c 100644
--- a/toxcore/DHT.c
+++ b/toxcore/DHT.c
@@ -200,8 +200,8 @@ static void get_close_nodes_inner(DHT *dht, uint8_t *client_id, Node_format *nod
200 time_t timestamp, int *num_nodes_ptr) 200 time_t timestamp, int *num_nodes_ptr)
201{ 201{
202 int num_nodes = *num_nodes_ptr; 202 int num_nodes = *num_nodes_ptr;
203 int i, tout, inlist, ipv46x, j, closest; 203 int tout, inlist, ipv46x, j, closest;
204 204 uint32_t i;
205 for (i = 0; i < client_list_length; i++) { 205 for (i = 0; i < client_list_length; i++) {
206 Client_data *client = &client_list[i]; 206 Client_data *client = &client_list[i];
207 tout = is_timeout(timestamp, client->timestamp, BAD_NODE_TIMEOUT); 207 tout = is_timeout(timestamp, client->timestamp, BAD_NODE_TIMEOUT);
@@ -726,10 +726,10 @@ static int handle_sendnodes(void *object, IP_Port source, uint8_t *packet, uint3
726#ifdef TOX_ENABLE_IPV6 726#ifdef TOX_ENABLE_IPV6
727 Node4_format *nodes4_list = (Node4_format *)(plain + sizeof(ping_id)); 727 Node4_format *nodes4_list = (Node4_format *)(plain + sizeof(ping_id));
728 728
729 int num_nodes_ok = 0; 729 uint32_t num_nodes_ok = 0;
730 730
731 for (i = 0; i < num_nodes; i++) 731 for (i = 0; i < num_nodes; i++)
732 if ((nodes4_list[i].ip_port.ip.uint32 != 0) && (nodes4_list[i].ip_port.ip.uint32 != ~0)) { 732 if ((nodes4_list[i].ip_port.ip.uint32 != 0) && (nodes4_list[i].ip_port.ip.uint32 != (uint32_t)~0)) {
733 memcpy(nodes_list[num_nodes_ok].client_id, nodes4_list[i].client_id, CLIENT_ID_SIZE); 733 memcpy(nodes_list[num_nodes_ok].client_id, nodes4_list[i].client_id, CLIENT_ID_SIZE);
734 nodes_list[num_nodes_ok].ip_port.ip.family = AF_INET; 734 nodes_list[num_nodes_ok].ip_port.ip.family = AF_INET;
735 nodes_list[num_nodes_ok].ip_port.ip.ip4.uint32 = nodes4_list[i].ip_port.ip.uint32; 735 nodes_list[num_nodes_ok].ip_port.ip.ip4.uint32 = nodes4_list[i].ip_port.ip.uint32;
@@ -1477,14 +1477,14 @@ void DHT_save(DHT *dht, uint8_t *data)
1477int DHT_load(DHT *dht, uint8_t *data, uint32_t size) 1477int DHT_load(DHT *dht, uint8_t *data, uint32_t size)
1478{ 1478{
1479 if (size < sizeof(dht->close_clientlist)) { 1479 if (size < sizeof(dht->close_clientlist)) {
1480 fprintf(stderr, "DHT_load: Expected at least %lu bytes, got %u.\n", sizeof(dht->close_clientlist), size); 1480 fprintf(stderr, "DHT_load: Expected at least %u bytes, got %u.\n", sizeof(dht->close_clientlist), size);
1481 return -1; 1481 return -1;
1482 } 1482 }
1483 1483
1484 uint32_t friendlistsize = size - sizeof(dht->close_clientlist); 1484 uint32_t friendlistsize = size - sizeof(dht->close_clientlist);
1485 1485
1486 if (friendlistsize % sizeof(DHT_Friend) != 0) { 1486 if (friendlistsize % sizeof(DHT_Friend) != 0) {
1487 fprintf(stderr, "DHT_load: Expected a multiple of %lu, got %u.\n", sizeof(DHT_Friend), friendlistsize); 1487 fprintf(stderr, "DHT_load: Expected a multiple of %u, got %u.\n", sizeof(DHT_Friend), friendlistsize);
1488 return -1; 1488 return -1;
1489 } 1489 }
1490 1490