[openssl-commits] [openssl] master update

Matt Caswell matt at openssl.org
Thu Nov 9 17:07:00 UTC 2017


The branch master has been updated
       via  44f19af7434cdb996f1ce11789150baa07db27e6 (commit)
      from  b6705d4893d1566c3a5427e387ce99344497758d (commit)


- Log -----------------------------------------------------------------
commit 44f19af7434cdb996f1ce11789150baa07db27e6
Author: Matt Caswell <matt at openssl.org>
Date:   Wed Nov 8 13:22:59 2017 +0000

    Fix an s_client memory leak
    
    We were using OPENSSL_strdup() unnecessarily and then failing to free it. There is
    no reason to use OPENSSL_strdup() in this scenario - so just remove it.
    
    Reviewed-by: Ben Kaduk <kaduk at mit.edu>
    (Merged from https://github.com/openssl/openssl/pull/4699)

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

Summary of changes:
 apps/s_client.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/apps/s_client.c b/apps/s_client.c
index d2aa01d..58ed1a5 100644
--- a/apps/s_client.c
+++ b/apps/s_client.c
@@ -918,7 +918,7 @@ int s_client_main(int argc, char **argv)
 #if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS)
     struct timeval tv;
 #endif
-    char *servername = NULL;
+    const char *servername = NULL;
     int noservername = 0;
     const char *alpn_in = NULL;
     tlsextctx tlsextcbp = { NULL, 0 };
@@ -1924,16 +1924,9 @@ int s_client_main(int argc, char **argv)
         }
         /* By default the SNI should be the same as was set in the session */
         if (!noservername && servername == NULL) {
-            const char *sni = SSL_SESSION_get0_hostname(sess);
+            servername = SSL_SESSION_get0_hostname(sess);
 
-            if (sni != NULL) {
-                servername = OPENSSL_strdup(sni);
-                if (servername == NULL) {
-                    BIO_printf(bio_err, "Can't set server name\n");
-                    ERR_print_errors(bio_err);
-                    goto end;
-                }
-            } else {
+            if (servername == NULL) {
                 /*
                  * Force no SNI to be sent so we are consistent with the
                  * session.


More information about the openssl-commits mailing list