aboutsummaryrefslogtreecommitdiff
path: root/demos
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2023-09-06 12:36:43 +0100
committerMatt Caswell <matt@openssl.org>2023-09-08 15:44:37 +0100
commit11b7d46fa7e2684e0ad0f12a7806163dba99983d (patch)
treef2349dd688bad7b70a1d907c6e3a9c568d2c223f /demos
parentcdedecd50351a3624b074e6a425d8dfb3af5fa6a (diff)
downloadopenssl-11b7d46fa7e2684e0ad0f12a7806163dba99983d.zip
openssl-11b7d46fa7e2684e0ad0f12a7806163dba99983d.tar.gz
openssl-11b7d46fa7e2684e0ad0f12a7806163dba99983d.tar.bz2
Return NULL if we fail to create a BIO in the demos/quicserver
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)
Diffstat (limited to 'demos')
-rw-r--r--demos/guide/quic-client-block.c6
-rw-r--r--demos/guide/quic-client-non-block.c6
-rw-r--r--demos/guide/quic-multi-stream.c7
-rw-r--r--demos/guide/tls-client-block.c4
-rw-r--r--demos/guide/tls-client-non-block.c6
5 files changed, 19 insertions, 10 deletions
diff --git a/demos/guide/quic-client-block.c b/demos/guide/quic-client-block.c
index 2c177b4..e6cabfe 100644
--- a/demos/guide/quic-client-block.c
+++ b/demos/guide/quic-client-block.c
@@ -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
diff --git a/demos/guide/quic-client-non-block.c b/demos/guide/quic-client-non-block.c
index e1735c0..61d339c 100644
--- a/demos/guide/quic-client-non-block.c
+++ b/demos/guide/quic-client-non-block.c
@@ -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
diff --git a/demos/guide/quic-multi-stream.c b/demos/guide/quic-multi-stream.c
index 8b6567a..56db5a9 100644
--- a/demos/guide/quic-multi-stream.c
+++ b/demos/guide/quic-multi-stream.c
@@ -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
diff --git a/demos/guide/tls-client-block.c b/demos/guide/tls-client-block.c
index b2d2a89..75ce7eb 100644
--- a/demos/guide/tls-client-block.c
+++ b/demos/guide/tls-client-block.c
@@ -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
diff --git a/demos/guide/tls-client-non-block.c b/demos/guide/tls-client-non-block.c
index dc6ee4d..14448c9 100644
--- a/demos/guide/tls-client-non-block.c
+++ b/demos/guide/tls-client-non-block.c
@@ -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