summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorDoug Hogan <doug@cvs.openbsd.org>2015-07-19 03:28:27 +0000
committerDoug Hogan <doug@cvs.openbsd.org>2015-07-19 03:28:27 +0000
commite21c3edac49f043437e2a2f973c20db89ad94b7f (patch)
tree5afebd037fa2081be8132081e281cf8ee72de4ed /usr.bin
parenta19cce7e93bebe533760af99de1f052cb9442ed6 (diff)
Only close descriptor if not already closed.
Fixes coverity 78916. ok miod@ bcook@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/openssl/s_socket.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/openssl/s_socket.c b/usr.bin/openssl/s_socket.c
index c49edf1d4e6..ccf49c5da5b 100644
--- a/usr.bin/openssl/s_socket.c
+++ b/usr.bin/openssl/s_socket.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: s_socket.c,v 1.5 2015/07/17 20:22:02 beck Exp $ */
+/* $OpenBSD: s_socket.c,v 1.6 2015/07/19 03:28:26 doug Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -83,7 +83,7 @@ int
init_client(int *sock, char *host, char *port, int type, int af)
{
struct addrinfo hints, *ai_top, *ai;
- int i, s;
+ int i, s = -1;
memset(&hints, '\0', sizeof(hints));
hints.ai_family = af;
@@ -120,11 +120,13 @@ init_client(int *sock, char *host, char *port, int type, int af)
return (1);
}
close(s);
+ s = -1;
}
perror("connect");
out:
- close(s);
+ if (s != -1)
+ close(s);
freeaddrinfo(ai_top);
return (0);
}