summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2013-03-19 10:58:21 +0100
committerTobias Klauser <tklauser@distanz.ch>2013-03-19 10:58:21 +0100
commite4c98bb91e35dba56a077e8e5b9c70556fdd4e24 (patch)
treee7469f9f3f96cd19779d6dc48f60e0d4b9ead3b2
parent0a021ca83742e2da23041c3fee602ba861dea6bb (diff)
curvetun: Only close() file descriptor if open
Only attempt to close the file descriptor in error cases where it is actually open. This was discovered by the coverity scanner. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
-rw-r--r--curvetun.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/curvetun.c b/curvetun.c
index 3e7bdb4..0baa9e4 100644
--- a/curvetun.c
+++ b/curvetun.c
@@ -280,7 +280,7 @@ static void create_keypair(char *home)
if (fd < 0) {
err = EIO;
errstr = "Cannot open pubkey file!\n";
- goto out;
+ goto out_noclose;
}
ret = write(fd, publickey, sizeof(publickey));
@@ -301,7 +301,7 @@ static void create_keypair(char *home)
if (fd < 0) {
err = EIO;
errstr = "Cannot open privkey file!\n";
- goto out;
+ goto out_noclose;
}
ret = write(fd, secretkey, sizeof(secretkey));
@@ -312,7 +312,7 @@ static void create_keypair(char *home)
}
out:
close(fd);
-
+out_noclose:
xmemset(publickey, 0, sizeof(publickey));
xmemset(secretkey, 0, sizeof(secretkey));