diff options
-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); |