summaryrefslogtreecommitdiffstats
path: root/lib/libssl/src
diff options
context:
space:
mode:
authordjm <djm@openbsd.org>2009-01-30 03:58:35 +0000
committerdjm <djm@openbsd.org>2009-01-30 03:58:35 +0000
commit6fcf363cf97153bd26e4f8ffcbe8c351cfae8fc1 (patch)
treebf58962e6f04c863c3fb997617198dc79891f349 /lib/libssl/src
parentremove some gratuitous changes that do nothing other than inrease (diff)
downloadwireguard-openbsd-6fcf363cf97153bd26e4f8ffcbe8c351cfae8fc1.tar.xz
wireguard-openbsd-6fcf363cf97153bd26e4f8ffcbe8c351cfae8fc1.zip
missing ssl_sock_init() call in init_client() (used by
"openssl s_client"), fix an unlikely memory leak
Diffstat (limited to 'lib/libssl/src')
-rw-r--r--lib/libssl/src/apps/s_socket.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/libssl/src/apps/s_socket.c b/lib/libssl/src/apps/s_socket.c
index 7e47d5118db..a91f5df919b 100644
--- a/lib/libssl/src/apps/s_socket.c
+++ b/lib/libssl/src/apps/s_socket.c
@@ -231,16 +231,23 @@ int init_client(int *sock, char *host, char *port, int type, int af)
struct addrinfo hints, *ai_top, *ai;
int i, s;
+ if (!ssl_sock_init()) return(0);
+
memset(&hints, '\0', sizeof(hints));
hints.ai_family = af;
hints.ai_socktype = type;
- if ((i = getaddrinfo(host, port, &hints, &ai_top)) != 0 ||
- ai_top == NULL || ai_top->ai_addr == NULL)
+ if ((i = getaddrinfo(host, port, &hints, &ai_top)) != 0)
{
BIO_printf(bio_err,"getaddrinfo: %s\n", gai_strerror(i));
return (0);
}
+ if (ai_top == NULL || ai_top->ai_addr == NULL)
+ {
+ BIO_printf(bio_err,"getaddrinfo returned no addresses\n");
+ if (ai_top != NULL) { freeaddrinfo(ai_top); }
+ return (0);
+ }
for (ai = ai_top; ai != NULL; ai = ai->ai_next)
{
@@ -255,7 +262,7 @@ int init_client(int *sock, char *host, char *port, int type, int af)
}
#endif
if ((i = connect(s, ai->ai_addr, ai->ai_addrlen)) == 0)
- { *sock=s; freeaddrinfo(ai_top); return (1);}
+ { *sock=s; freeaddrinfo(ai_top); return (1); }
close(s);
}