]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
apps/lib/s_socket.c: Fix mem leak on host name in init_client()
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>
Wed, 29 Sep 2021 08:46:23 +0000 (10:46 +0200)
committerTomas Mraz <tomas@openssl.org>
Mon, 4 Oct 2021 08:55:39 +0000 (10:55 +0200)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16688)

apps/lib/s_socket.c

index 1dd30ac7242a58be666236cd39ca527359bb5267..4e262e681d69e39f7a0154982b6ea1ae0ff04825 100644 (file)
@@ -82,6 +82,7 @@ int init_client(int *sock, const char *host, const char *port,
     BIO_ADDRINFO *bindaddr = NULL;
     const BIO_ADDRINFO *ai = NULL;
     const BIO_ADDRINFO *bi = NULL;
+    char *hostname = NULL;
     int found = 0;
     int ret;
 
@@ -172,7 +173,9 @@ int init_client(int *sock, const char *host, const char *port,
         break;
     }
 
-    BIO_printf(bio_out, "Connecting to %s\n", BIO_ADDR_hostname_string(BIO_ADDRINFO_address(ai), 1));
+    hostname = BIO_ADDR_hostname_string(BIO_ADDRINFO_address(ai), 1);
+    BIO_printf(bio_out, "Connecting to %s\n", hostname);
+    OPENSSL_free(hostname);
 
     if (*sock == INVALID_SOCKET) {
         if (bindaddr != NULL && !found) {