diff options
author | Dimitri Staessens <[email protected]> | 2022-02-25 00:15:28 +0100 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2022-03-03 12:00:53 +0100 |
commit | 27374c05645cb6a656e82a9a0b6bc810082cfe4e (patch) | |
tree | 9177d572965d352ca606e5535a5971e91fddde4a /src/ipcpd/unicast | |
parent | 9719dbe335af4c6add39d739f78a68040b62d8a3 (diff) | |
download | ouroboros-27374c05645cb6a656e82a9a0b6bc810082cfe4e.tar.gz ouroboros-27374c05645cb6a656e82a9a0b6bc810082cfe4e.zip |
ipcpd: Fix some unchecked return values
Fixes some unchecked and wrongly checked return values.
Signed-off-by: Dimitri Staessens <[email protected]>
Signed-off-by: Sander Vrijders <[email protected]>
Diffstat (limited to 'src/ipcpd/unicast')
-rw-r--r-- | src/ipcpd/unicast/dir/dht.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/ipcpd/unicast/dir/dht.c b/src/ipcpd/unicast/dir/dht.c index d84da9da..572010b7 100644 --- a/src/ipcpd/unicast/dir/dht.c +++ b/src/ipcpd/unicast/dir/dht.c @@ -1269,7 +1269,7 @@ static void bucket_refresh(struct dht * dht, struct contact * d; c = list_first_entry(&b->contacts, struct contact, next); d = contact_create(c->id, dht->b, c->addr); - if (c != NULL) + if (d != NULL) list_add(&d->next, r); return; } @@ -1912,11 +1912,11 @@ static buffer_t dht_retrieve(struct dht * dht, if (buf.len == 0) goto fail; - buf.data = malloc(sizeof(dht->addr) * buf.len); - if (buf.data == NULL) + pos = malloc(sizeof(dht->addr) * buf.len); + if (pos == NULL) goto fail; - pos = (uint64_t *) buf.data; + buf.data = (uint8_t *) pos; list_for_each(p, &e->vals) { struct val * v = list_entry(p, struct val, next); @@ -1931,8 +1931,8 @@ static buffer_t dht_retrieve(struct dht * dht, fail: pthread_rwlock_unlock(&dht->lock); - buf.len = 0; - + buf.len = 0; + buf.data = NULL; return buf; } @@ -2844,7 +2844,8 @@ void * dht_create(void) if ((int) dht->eid < 0) goto fail_tpm_start; - notifier_reg(handle_event, dht); + if (notifier_reg(handle_event, dht)) + goto fail_notifier_reg; #else (void) handle_event; (void) dht_handle_packet; @@ -2854,6 +2855,8 @@ void * dht_create(void) return (void *) dht; #ifndef __DHT_TEST__ + fail_notifier_reg: + tpm_stop(dht->tpm); fail_tpm_start: tpm_destroy(dht->tpm); fail_tpm_create: |