]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
apps/s_client.c: add missing null check
authorKaoruToda <kunnpuu@gmail.com>
Thu, 19 Oct 2017 14:41:03 +0000 (23:41 +0900)
committerAndy Polyakov <appro@openssl.org>
Sun, 22 Oct 2017 19:31:20 +0000 (21:31 +0200)
apps/s_server.c: remove unnecessary null check

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4558)

apps/s_client.c
apps/s_server.c

index 96bfc159d7ae34c8278924f76c92ff54dba943c8..019e73535a84261c63aed551eac40a066a791686 100644 (file)
@@ -1866,6 +1866,9 @@ int s_client_main(int argc, char **argv)
         goto end;
 
     con = SSL_new(ctx);
+    if (con == NULL)
+        goto end;
+
     if (sess_in != NULL) {
         SSL_SESSION *sess;
         BIO *stmp = BIO_new_file(sess_in, "r");
index a7d85f3849ab2c111756a8233cf65eb572fad52e..311f4a217c96daf53585d78801cbfe8b65dd0fc3 100644 (file)
@@ -2202,22 +2202,25 @@ static int sv_body(int s, int stype, int prot, unsigned char *context)
             BIO_printf(bio_err, "Turned on non blocking io\n");
     }
 
+    con = SSL_new(ctx);
     if (con == NULL) {
-        con = SSL_new(ctx);
+        ret = -1;
+        goto err;
+    }
 
-        if (s_tlsextdebug) {
-            SSL_set_tlsext_debug_callback(con, tlsext_cb);
-            SSL_set_tlsext_debug_arg(con, bio_s_out);
-        }
+    if (s_tlsextdebug) {
+        SSL_set_tlsext_debug_callback(con, tlsext_cb);
+        SSL_set_tlsext_debug_arg(con, bio_s_out);
+    }
 
-        if (context
-            && !SSL_set_session_id_context(con,
-                                           context, strlen((char *)context))) {
-            BIO_printf(bio_err, "Error setting session id context\n");
-            ret = -1;
-            goto err;
-        }
+    if (context != NULL
+        && !SSL_set_session_id_context(con, context,
+                                       strlen((char *)context))) {
+        BIO_printf(bio_err, "Error setting session id context\n");
+        ret = -1;
+        goto err;
     }
+
     if (!SSL_clear(con)) {
         BIO_printf(bio_err, "Error clearing SSL connection\n");
         ret = -1;