[openssl] master update

tomas at openssl.org tomas at openssl.org
Wed Oct 6 15:23:46 UTC 2021


The branch master has been updated
       via  e8655e16cab9cd14ebfe9f2214c2f2aa39c67a26 (commit)
      from  64da15c40d15aac58e211fd25d00e9ae84d0379b (commit)


- Log -----------------------------------------------------------------
commit e8655e16cab9cd14ebfe9f2214c2f2aa39c67a26
Author: Tomas Mraz <tomas at openssl.org>
Date:   Mon Oct 4 11:19:33 2021 +0200

    s_socket.c: Avoid possible NULL pointer dereference
    
    Reviewed-by: Dmitry Belyavskiy <beldmit at gmail.com>
    Reviewed-by: Bernd Edlinger <bernd.edlinger at hotmail.de>
    (Merged from https://github.com/openssl/openssl/pull/16736)

-----------------------------------------------------------------------

Summary of changes:
 apps/lib/s_socket.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/apps/lib/s_socket.c b/apps/lib/s_socket.c
index 4e262e681d..805a1f0f3d 100644
--- a/apps/lib/s_socket.c
+++ b/apps/lib/s_socket.c
@@ -82,7 +82,6 @@ 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;
 
@@ -173,10 +172,6 @@ int init_client(int *sock, const char *host, const char *port,
         break;
     }
 
-    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) {
             BIO_printf(bio_err, "Can't bind %saddress for %s%s%s\n",
@@ -193,6 +188,13 @@ int init_client(int *sock, const char *host, const char *port,
         }
         ERR_print_errors(bio_err);
     } else {
+        char *hostname = NULL;
+
+        hostname = BIO_ADDR_hostname_string(BIO_ADDRINFO_address(ai), 1);
+        if (hostname != NULL) {
+            BIO_printf(bio_out, "Connecting to %s\n", hostname);
+            OPENSSL_free(hostname);
+        }
         /* Remove any stale errors from previous connection attempts */
         ERR_clear_error();
         ret = 1;


More information about the openssl-commits mailing list