diff options
author | Dimitri Staessens <dimitri@ouroboros.rocks> | 2023-12-18 13:22:37 +0100 |
---|---|---|
committer | Sander Vrijders <sander@ouroboros.rocks> | 2023-12-31 16:47:55 +0100 |
commit | 863553891b296c5574d6b0893ad21fe16b97a6ea (patch) | |
tree | 4b71169f7aea62a0c043ff85d9597b9e395b26bd | |
parent | 9ecb29b3691df17c0beec56ddf4f27160bb3ef58 (diff) | |
download | ouroboros-863553891b296c5574d6b0893ad21fe16b97a6ea.tar.gz ouroboros-863553891b296c5574d6b0893ad21fe16b97a6ea.zip |
irmd: Fix passing symmetric key on allocation
The check if the flow requires a key in irmd flow_alloc was missing
when setting the pointers for the piggyback data, so non-encrypted
flow allocations failed on irm_msg__pack().
Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks>
Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
-rw-r--r-- | src/irmd/main.c | 12 | ||||
-rw-r--r-- | src/lib/dev.c | 2 |
2 files changed, 9 insertions, 5 deletions
diff --git a/src/irmd/main.c b/src/irmd/main.c index 59c1c5ec..4284b4c5 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -1507,6 +1507,8 @@ static int flow_accept(pid_t pid, if (f_out->qs.cypher_s > 0) { data->data = s; data->len = SYMMKEYSZ; + } else { + free(s); } log_info("Flow on flow_id %d allocated.", f->flow_id); @@ -1626,7 +1628,7 @@ static int flow_alloc(pid_t pid, uint8_t * hash; ssize_t key_len; void * pkp; /* my public key pair */ - buffer_t tmp; /* buffer for public key */ + buffer_t tmp = {NULL, 0}; /* buffer for public key */ uint8_t buf[MSGBUFSZ]; uint8_t * s = NULL; int err; @@ -1741,10 +1743,12 @@ static int flow_alloc(pid_t pid, pthread_rwlock_unlock(&irmd.reg_lock); free(hash); - crypt_dh_pkp_destroy(pkp); - data->data = s; - data->len = SYMMKEYSZ; + if (qs.cypher_s > 0) { + crypt_dh_pkp_destroy(pkp); + data->data = s; + data->len = SYMMKEYSZ; + } log_info("Flow on flow_id %d allocated.", flow_id); diff --git a/src/lib/dev.c b/src/lib/dev.c index acf18da2..74a8c62d 100644 --- a/src/lib/dev.c +++ b/src/lib/dev.c @@ -475,7 +475,7 @@ static int flow_init(int flow_id, flow->crypt.flags = qs.cypher_s; /* TODO: remove cypher_s from qos */ - if (flow->crypt.flags > 0) + if (flow->crypt.flags > 0 && s != NULL) /* static analyzer s != NULL */ memcpy(flow->crypt.key, s ,SYMMKEYSZ); else memset(flow->crypt.key, 0, SYMMKEYSZ); |