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 /src/irmd/main.c | |
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>
Diffstat (limited to 'src/irmd/main.c')
-rw-r--r-- | src/irmd/main.c | 12 |
1 files changed, 8 insertions, 4 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); |