summaryrefslogtreecommitdiff
path: root/curvetun_mgmt_users.c
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2015-09-07 17:24:56 +0200
committerTobias Klauser <tklauser@distanz.ch>2015-09-07 17:24:56 +0200
commit047d69c4eb2cefe9bab654fb570592d3863da792 (patch)
tree1aa5a0957501bc6bf901af3843f265954b1ed966 /curvetun_mgmt_users.c
parentf472d90b141d0e9f0c1033012d6d2be1338b7b1f (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>
Diffstat (limited to 'curvetun_mgmt_users.c')
-rw-r--r--curvetun_mgmt_users.c13
1 files changed, 10 insertions, 3 deletions
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;
}