]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Return NULL if we fail to create a BIO in the demos/quicserver
authorMatt Caswell <matt@openssl.org>
Wed, 6 Sep 2023 11:36:43 +0000 (12:36 +0100)
committerMatt Caswell <matt@openssl.org>
Fri, 8 Sep 2023 14:44:37 +0000 (15:44 +0100)
Strictly speaking the previous code was still correct since BIO_set_fd
is tolerant of a NULL BIO. But this way is more clear.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21950)

demos/guide/quic-client-block.c
demos/guide/quic-client-non-block.c
demos/guide/quic-multi-stream.c
demos/guide/tls-client-block.c
demos/guide/tls-client-non-block.c
doc/man7/ossl-guide-quic-client-block.pod
doc/man7/ossl-guide-tls-client-block.pod
util/quicserver.c

index 2c177b4f187fb04ad7f8203f23f81503cbc0403a..e6cabfef260a8cfa2ef7c2b825d5b561c03e28e1 100644 (file)
@@ -89,10 +89,12 @@ static BIO *create_socket_bio(const char *hostname, const char *port,
     if (sock == -1)
         return NULL;
 
-    /* Create a BIO to wrap the socket*/
+    /* Create a BIO to wrap the socket */
     bio = BIO_new(BIO_s_datagram());
-    if (bio == NULL)
+    if (bio == NULL) {
         BIO_closesocket(sock);
+        return NULL;
+    }
 
     /*
      * Associate the newly created BIO with the underlying socket. By
index e1735c0c5d261bdd5fe16b1d8bdf45c164d8dc96..61d339c79ca57b4244abf7ea82884e36f2a4c5b0 100644 (file)
@@ -90,10 +90,12 @@ static BIO *create_socket_bio(const char *hostname, const char *port,
     if (sock == -1)
         return NULL;
 
-    /* Create a BIO to wrap the socket*/
+    /* Create a BIO to wrap the socket */
     bio = BIO_new(BIO_s_datagram());
-    if (bio == NULL)
+    if (bio == NULL) {
         BIO_closesocket(sock);
+        return NULL;
+    }
 
     /*
      * Associate the newly created BIO with the underlying socket. By
index 8b6567aa8377610b4c6425f1a330749c800899ef..56db5a98a8b40953790aeb2e7646c8098a20de2c 100644 (file)
@@ -90,11 +90,12 @@ static BIO *create_socket_bio(const char *hostname, const char *port,
     if (sock == -1)
         return NULL;
 
-    /* Create a BIO to wrap the socket*/
+    /* Create a BIO to wrap the socket */
     bio = BIO_new(BIO_s_datagram());
-    if (bio == NULL)
+    if (bio == NULL) {
         BIO_closesocket(sock);
-
+        return NULL;
+    }
     /*
      * Associate the newly created BIO with the underlying socket. By
      * passing BIO_CLOSE here the socket will be automatically closed when
index b2d2a89dd139faf1d25d2ad901f7692497f9a97d..75ce7ebcc2458f9ce74a6ebb5fe08df3a77a2c17 100644 (file)
@@ -76,8 +76,10 @@ static BIO *create_socket_bio(const char *hostname, const char *port)
 
     /* Create a BIO to wrap the socket*/
     bio = BIO_new(BIO_s_socket());
-    if (bio == NULL)
+    if (bio == NULL) {
         BIO_closesocket(sock);
+        return NULL;
+    }
 
     /*
      * Associate the newly created BIO with the underlying socket. By
index dc6ee4dce8985b85c3787740eba3c540cb9d1198..14448c968523e69d0c5e9372ad134046becc56c9 100644 (file)
@@ -81,10 +81,12 @@ static BIO *create_socket_bio(const char *hostname, const char *port)
     if (sock == -1)
         return NULL;
 
-    /* Create a BIO to wrap the socket*/
+    /* Create a BIO to wrap the socket */
     bio = BIO_new(BIO_s_socket());
-    if (bio == NULL)
+    if (bio == NULL) {
         BIO_closesocket(sock);
+        return NULL;
+    }
 
     /*
      * Associate the newly created BIO with the underlying socket. By
index 4cf8bdd3b828978a3212f2168692a9afd5ba0f9c..fc8912086dae6419dd10f53aa14bc0d2218bf197 100644 (file)
@@ -165,10 +165,12 @@ associate it with a BIO object:
 
     BIO *bio;
 
-    /* Create a BIO to wrap the socket*/
+    /* Create a BIO to wrap the socket */
     bio = BIO_new(BIO_s_datagram());
-    if (bio == NULL)
+    if (bio == NULL) {
         BIO_closesocket(sock);
+        return NULL;
+    }
 
     /*
      * Associate the newly created BIO with the underlying socket. By
index 236553fafd53465f5073428c82378273b3874d9d..865a5353b3fa3322519e324f1531099c6cbb9f4e 100644 (file)
@@ -222,10 +222,12 @@ BIO object:
 
     BIO *bio;
 
-    /* Create a BIO to wrap the socket*/
+    /* Create a BIO to wrap the socket */
     bio = BIO_new(BIO_s_socket());
-    if (bio == NULL)
+    if (bio == NULL) {
         BIO_closesocket(sock);
+        return NULL;
+    }
 
     /*
      * Associate the newly created BIO with the underlying socket. By
index 5a51b240ffdf7669e6ea38a1849a7e365cd64c6c..fd9f9399bd6e2219d03694863061b9f79953e1e7 100644 (file)
@@ -113,10 +113,12 @@ static BIO *create_dgram_bio(int family, const char *hostname, const char *port)
     if (sock == -1)
         return NULL;
 
-    /* Create a BIO to wrap the socket*/
+    /* Create a BIO to wrap the socket */
     bio = BIO_new(BIO_s_datagram());
-    if (bio == NULL)
+    if (bio == NULL) {
         BIO_closesocket(sock);
+        return NULL;
+    }
 
     /*
      * Associate the newly created BIO with the underlying socket. By