diff options
| author | doug <> | 2015-07-19 03:28:26 +0000 |
|---|---|---|
| committer | doug <> | 2015-07-19 03:28:26 +0000 |
| commit | 09a8a5849adba3406d2aeabaa5505f868a159bdb (patch) | |
| tree | 1b368247e08376768787e89b66ce0a28269f2a53 /src | |
| parent | e17b32ff6f83b12666f81b74908144ef8ce8211f (diff) | |
| download | openbsd-09a8a5849adba3406d2aeabaa5505f868a159bdb.tar.gz openbsd-09a8a5849adba3406d2aeabaa5505f868a159bdb.tar.bz2 openbsd-09a8a5849adba3406d2aeabaa5505f868a159bdb.zip | |
Only close descriptor if not already closed.
Fixes coverity 78916.
ok miod@ bcook@
Diffstat (limited to 'src')
| -rw-r--r-- | src/usr.bin/openssl/s_socket.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/usr.bin/openssl/s_socket.c b/src/usr.bin/openssl/s_socket.c index c49edf1d4e..ccf49c5da5 100644 --- a/src/usr.bin/openssl/s_socket.c +++ b/src/usr.bin/openssl/s_socket.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: s_socket.c,v 1.5 2015/07/17 20:22:02 beck Exp $ */ | 1 | /* $OpenBSD: s_socket.c,v 1.6 2015/07/19 03:28:26 doug Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -83,7 +83,7 @@ int | |||
| 83 | init_client(int *sock, char *host, char *port, int type, int af) | 83 | init_client(int *sock, char *host, char *port, int type, int af) |
| 84 | { | 84 | { |
| 85 | struct addrinfo hints, *ai_top, *ai; | 85 | struct addrinfo hints, *ai_top, *ai; |
| 86 | int i, s; | 86 | int i, s = -1; |
| 87 | 87 | ||
| 88 | memset(&hints, '\0', sizeof(hints)); | 88 | memset(&hints, '\0', sizeof(hints)); |
| 89 | hints.ai_family = af; | 89 | hints.ai_family = af; |
| @@ -120,11 +120,13 @@ init_client(int *sock, char *host, char *port, int type, int af) | |||
| 120 | return (1); | 120 | return (1); |
| 121 | } | 121 | } |
| 122 | close(s); | 122 | close(s); |
| 123 | s = -1; | ||
| 123 | } | 124 | } |
| 124 | 125 | ||
| 125 | perror("connect"); | 126 | perror("connect"); |
| 126 | out: | 127 | out: |
| 127 | close(s); | 128 | if (s != -1) |
| 129 | close(s); | ||
| 128 | freeaddrinfo(ai_top); | 130 | freeaddrinfo(ai_top); |
| 129 | return (0); | 131 | return (0); |
| 130 | } | 132 | } |
