summaryrefslogtreecommitdiff
path: root/toxcore/DHT.c
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2015-12-10 10:09:48 -0500
committerirungentoo <irungentoo@gmail.com>2015-12-10 10:09:48 -0500
commit39700abd86cb2ffb13c8a428ddd75a00866f8a21 (patch)
tree907e7f44323a83134970f993191fbe056d87be9b /toxcore/DHT.c
parent8fa264e7709d64377f688fc9efce528ebd75618f (diff)
Check if node can be stored before sorting.
Diffstat (limited to 'toxcore/DHT.c')
-rw-r--r--toxcore/DHT.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/toxcore/DHT.c b/toxcore/DHT.c
index 1edc86ae..dc640562 100644
--- a/toxcore/DHT.c
+++ b/toxcore/DHT.c
@@ -733,15 +733,15 @@ static int replace_all( Client_data *list,
733 if ((ip_port.ip.family != AF_INET) && (ip_port.ip.family != AF_INET6)) 733 if ((ip_port.ip.family != AF_INET) && (ip_port.ip.family != AF_INET6))
734 return 0; 734 return 0;
735 735
736 memcpy(cmp_public_key, comp_public_key, crypto_box_PUBLICKEYBYTES); 736 if (store_node_ok(&list[1], public_key, comp_public_key)) {
737 qsort(list, length, sizeof(Client_data), cmp_dht_entry); 737 memcpy(cmp_public_key, comp_public_key, crypto_box_PUBLICKEYBYTES);
738 qsort(list, length, sizeof(Client_data), cmp_dht_entry);
738 739
739 Client_data *client = &list[0];
740
741 if (store_node_ok(client, public_key, comp_public_key)) {
742 IPPTsPng *ipptp_write = NULL; 740 IPPTsPng *ipptp_write = NULL;
743 IPPTsPng *ipptp_clear = NULL; 741 IPPTsPng *ipptp_clear = NULL;
744 742
743 Client_data *client = &list[0];
744
745 if (ip_port.ip.family == AF_INET) { 745 if (ip_port.ip.family == AF_INET) {
746 ipptp_write = &client->assoc4; 746 ipptp_write = &client->assoc4;
747 ipptp_clear = &client->assoc6; 747 ipptp_clear = &client->assoc6;
@@ -1375,7 +1375,6 @@ static void divide_by_2(uint8_t *public_key)
1375static void find_midpoint(uint8_t *out, const uint8_t *top, const uint8_t *bot) 1375static void find_midpoint(uint8_t *out, const uint8_t *top, const uint8_t *bot)
1376{ 1376{
1377 unsigned int i; 1377 unsigned int i;
1378 _Bool one = 0;
1379 1378
1380 for (i = 0; i < crypto_box_PUBLICKEYBYTES; ++i) { 1379 for (i = 0; i < crypto_box_PUBLICKEYBYTES; ++i) {
1381 out[i] = top[i] ^ bot[i]; 1380 out[i] = top[i] ^ bot[i];