s_time: check return values better
authorPauli <paul.dale@oracle.com>
Mon, 7 Sep 2020 21:35:29 +0000 (07:35 +1000)
committerPauli <paul.dale@oracle.com>
Wed, 9 Sep 2020 08:01:05 +0000 (18:01 +1000)
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/12808)

apps/s_time.c

index ac9c72e62251df57e5e8a1dba66d1a8f22a0d684..3730ca540a23b3b1f02333b12343a9f51da3e9f7 100644 (file)
@@ -416,12 +416,19 @@ static SSL *doConnection(SSL *scon, const char *host, SSL_CTX *ctx)
     if ((conn = BIO_new(BIO_s_connect())) == NULL)
         return NULL;
 
-    BIO_set_conn_hostname(conn, host);
-    BIO_set_conn_mode(conn, BIO_SOCK_NODELAY);
+    if (BIO_set_conn_hostname(conn, host) <= 0
+            || BIO_set_conn_mode(conn, BIO_SOCK_NODELAY) <= 0) {
+        BIO_free(conn);
+        return NULL;
+    }
 
-    if (scon == NULL)
+    if (scon == NULL) {
         serverCon = SSL_new(ctx);
-    else {
+        if (serverCon == NULL) {
+            BIO_free(conn);
+            return NULL;
+        }
+    } else {
         serverCon = scon;
         SSL_set_connect_state(serverCon);
     }