summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordjm <>2009-01-30 03:58:35 +0000
committerdjm <>2009-01-30 03:58:35 +0000
commite47d1e5623f7b21607cbaca3b534336be3605d42 (patch)
tree40cd6715a6dab2d94b730c60051236964bbecab5
parent8531d6a47f499006aa2c2a5c41809ee5886137e2 (diff)
downloadopenbsd-e47d1e5623f7b21607cbaca3b534336be3605d42.tar.gz
openbsd-e47d1e5623f7b21607cbaca3b534336be3605d42.tar.bz2
openbsd-e47d1e5623f7b21607cbaca3b534336be3605d42.zip
missing ssl_sock_init() call in init_client() (used by
"openssl s_client"), fix an unlikely memory leak
-rw-r--r--src/lib/libssl/src/apps/s_socket.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/lib/libssl/src/apps/s_socket.c b/src/lib/libssl/src/apps/s_socket.c
index 7e47d5118d..a91f5df919 100644
--- a/src/lib/libssl/src/apps/s_socket.c
+++ b/src/lib/libssl/src/apps/s_socket.c
@@ -231,16 +231,23 @@ int init_client(int *sock, char *host, char *port, int type, int af)
231 struct addrinfo hints, *ai_top, *ai; 231 struct addrinfo hints, *ai_top, *ai;
232 int i, s; 232 int i, s;
233 233
234 if (!ssl_sock_init()) return(0);
235
234 memset(&hints, '\0', sizeof(hints)); 236 memset(&hints, '\0', sizeof(hints));
235 hints.ai_family = af; 237 hints.ai_family = af;
236 hints.ai_socktype = type; 238 hints.ai_socktype = type;
237 239
238 if ((i = getaddrinfo(host, port, &hints, &ai_top)) != 0 || 240 if ((i = getaddrinfo(host, port, &hints, &ai_top)) != 0)
239 ai_top == NULL || ai_top->ai_addr == NULL)
240 { 241 {
241 BIO_printf(bio_err,"getaddrinfo: %s\n", gai_strerror(i)); 242 BIO_printf(bio_err,"getaddrinfo: %s\n", gai_strerror(i));
242 return (0); 243 return (0);
243 } 244 }
245 if (ai_top == NULL || ai_top->ai_addr == NULL)
246 {
247 BIO_printf(bio_err,"getaddrinfo returned no addresses\n");
248 if (ai_top != NULL) { freeaddrinfo(ai_top); }
249 return (0);
250 }
244 251
245 for (ai = ai_top; ai != NULL; ai = ai->ai_next) 252 for (ai = ai_top; ai != NULL; ai = ai->ai_next)
246 { 253 {
@@ -255,7 +262,7 @@ int init_client(int *sock, char *host, char *port, int type, int af)
255 } 262 }
256#endif 263#endif
257 if ((i = connect(s, ai->ai_addr, ai->ai_addrlen)) == 0) 264 if ((i = connect(s, ai->ai_addr, ai->ai_addrlen)) == 0)
258 { *sock=s; freeaddrinfo(ai_top); return (1);} 265 { *sock=s; freeaddrinfo(ai_top); return (1); }
259 266
260 close(s); 267 close(s);
261 } 268 }