diff options
author | Dimitri Staessens <dimitri@ouroboros.rocks> | 2022-02-15 22:03:17 +0100 |
---|---|---|
committer | Sander Vrijders <sander@ouroboros.rocks> | 2022-02-17 08:28:56 +0100 |
commit | 6804b725dcc99437e8dc1330447330b08e3c39b8 (patch) | |
tree | 9f91ac26dcc516171fbf8bec99ee9c058d087afb | |
parent | 4aae321f11e3087d4e4bf65f945e5800f1d4f2c5 (diff) | |
download | ouroboros-6804b725dcc99437e8dc1330447330b08e3c39b8.tar.gz ouroboros-6804b725dcc99437e8dc1330447330b08e3c39b8.zip |
ipcpd: Fix initialization of hash width in DHT
The width of the Kademlia hash function (dht->b) was set only after
the ID was created. This should have failed miserably, but the bytes
after were fine as they were just a randomized ID in the Kademlia
network. Nasty.
Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks>
Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
-rw-r--r-- | src/ipcpd/unicast/dir/dht.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/ipcpd/unicast/dir/dht.c b/src/ipcpd/unicast/dir/dht.c index 1742267b..959fc179 100644 --- a/src/ipcpd/unicast/dir/dht.c +++ b/src/ipcpd/unicast/dir/dht.c @@ -2249,6 +2249,12 @@ int dht_bootstrap(void * dir) pthread_rwlock_wrlock(&dht->lock); +#ifndef __DHT_TEST__ + dht->b = hash_len(ipcpi.dir_hash_algo); +#else + dht->b = DHT_TEST_KEY_LEN; +#endif + dht->id = create_id(dht->b); if (dht->id == NULL) goto fail_id; @@ -2259,11 +2265,7 @@ int dht_bootstrap(void * dir) dht->buckets->depth = 0; dht->buckets->mask = 0; -#ifndef __DHT_TEST__ - dht->b = hash_len(ipcpi.dir_hash_algo); -#else - dht->b = DHT_TEST_KEY_LEN; -#endif + dht->t_expire = 86400; /* 1 day */ dht->t_repub = dht->t_expire - 10; dht->k = KAD_K; |