summaryrefslogtreecommitdiff
path: root/src/ipcpd
diff options
context:
space:
mode:
authorDimitri Staessens <[email protected]>2022-02-17 20:06:32 +0100
committerSander Vrijders <[email protected]>2022-02-18 08:43:14 +0100
commitc8d38bc1d9d578a884d4aa661a928c53c18d77fd (patch)
tree864e63a557797a7323f91a0cc7258050c279b3af /src/ipcpd
parent4fe23eccc3a62b02289964391a0cd611db89ed8b (diff)
downloadouroboros-c8d38bc1d9d578a884d4aa661a928c53c18d77fd.tar.gz
ouroboros-c8d38bc1d9d578a884d4aa661a928c53c18d77fd.zip
ipcpd: Fix deadlock in dht_unreg
The dht_del function was called under lock in dht_unreg, and then tried to take the lock again, a 100% deadlock. Also fix uninitialized value in dht_retrieve. Signed-off-by: Dimitri Staessens <[email protected]> Signed-off-by: Sander Vrijders <[email protected]>
Diffstat (limited to 'src/ipcpd')
-rw-r--r--src/ipcpd/unicast/dir/dht.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/ipcpd/unicast/dir/dht.c b/src/ipcpd/unicast/dir/dht.c
index 959fc179..d84da9da 100644
--- a/src/ipcpd/unicast/dir/dht.c
+++ b/src/ipcpd/unicast/dir/dht.c
@@ -1883,18 +1883,13 @@ static int dht_del(struct dht * dht,
{
struct dht_entry * e;
- pthread_rwlock_wrlock(&dht->lock);
-
e = dht_find_entry(dht, key);
if (e == NULL) {
- pthread_rwlock_unlock(&dht->lock);
return -EPERM;
}
dht_entry_del_addr(e, addr);
- pthread_rwlock_unlock(&dht->lock);
-
return 0;
}
@@ -1917,11 +1912,11 @@ static buffer_t dht_retrieve(struct dht * dht,
if (buf.len == 0)
goto fail;
- pos = malloc(sizeof(dht->addr) * buf.len);
- if (pos == NULL)
+ buf.data = malloc(sizeof(dht->addr) * buf.len);
+ if (buf.data == NULL)
goto fail;
- buf.data = (uint8_t *) pos;
+ pos = (uint64_t *) buf.data;
list_for_each(p, &e->vals) {
struct val * v = list_entry(p, struct val, next);