diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2015-09-07 17:24:56 +0200 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2015-09-07 17:24:56 +0200 |
commit | 047d69c4eb2cefe9bab654fb570592d3863da792 (patch) | |
tree | 1aa5a0957501bc6bf901af3843f265954b1ed966 | |
parent | f472d90b141d0e9f0c1033012d6d2be1338b7b1f (diff) |
curvetun: Fix issues detected by the Coverity scanner
Fix two issues detected by the Coverity scanner (CID 991819 & CID
991822)
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
-rw-r--r-- | curvetun.c | 4 | ||||
-rw-r--r-- | curvetun_mgmt_users.c | 13 |
2 files changed, 12 insertions, 5 deletions
@@ -328,7 +328,7 @@ static void check_config_keypair_or_die(char *home) if (fd < 0) { err = EIO; errstr = "Cannot open privkey file!\n"; - goto out; + goto out_noclose; } ret = read(fd, secretkey, sizeof(secretkey)); @@ -368,7 +368,7 @@ static void check_config_keypair_or_die(char *home) } out: close(fd); - +out_noclose: xmemset(publickey, 0, sizeof(publickey)); xmemset(publicres, 0, sizeof(publicres)); xmemset(secretkey, 0, sizeof(secretkey)); diff --git a/curvetun_mgmt_users.c b/curvetun_mgmt_users.c index 665ceb3..52b20d8 100644 --- a/curvetun_mgmt_users.c +++ b/curvetun_mgmt_users.c @@ -206,17 +206,23 @@ static int parse_line(char *line, char *homedir) for (; str != NULL;) { switch (s) { case PARSE_USERNAME: - if (__check_duplicate_username(str, strlen(str) + 1)) + if (__check_duplicate_username(str, strlen(str) + 1)) { + user_store_free(elem); return -EINVAL; + } strlcpy(elem->username, str, sizeof(elem->username)); s = PARSE_PUBKEY; break; case PARSE_PUBKEY: if (!curve25519_pubkey_hexparse_32(pkey, sizeof(pkey), - str, strlen(str))) + str, strlen(str))) { + user_store_free(elem); return -EINVAL; - if (__check_duplicate_pubkey(pkey, sizeof(pkey))) + } + if (__check_duplicate_pubkey(pkey, sizeof(pkey))) { + user_store_free(elem); return -EINVAL; + } memcpy(elem->publickey, pkey, sizeof(elem->publickey)); curve25519_proto_init(&elem->proto_inf, elem->publickey, sizeof(elem->publickey)); s = PARSE_DONE; @@ -224,6 +230,7 @@ static int parse_line(char *line, char *homedir) case PARSE_DONE: break; default: + user_store_free(elem); return -EIO; } |