]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
apps/s_socket: fix FD and addrinfo leak on SCTP failure in init_client
authorJoshua Rogers <MegaManSec@users.noreply.github.com>
Sat, 11 Oct 2025 22:34:40 +0000 (06:34 +0800)
committerTomas Mraz <tomas@openssl.org>
Tue, 18 Nov 2025 16:59:50 +0000 (17:59 +0100)
If BIO_new_dgram_sctp(*sock, BIO_NOCLOSE) fails we returned 0 directly,
skipping the out: cleanup and leaking the just created socket plus the
addrinfo lists.

Signed-off-by: Joshua Rogers <MegaManSec@users.noreply.github.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/28917)

apps/lib/s_socket.c

index d0dad64aa57dab906f43233b74ed52787f037fba..06b183bc23720fe904b0b060c495645c60a1f288 100644 (file)
@@ -154,8 +154,9 @@ int init_client(int *sock, const char *host, const char *port,
             BIO *tmpbio = BIO_new_dgram_sctp(*sock, BIO_NOCLOSE);
 
             if (tmpbio == NULL) {
-                ERR_print_errors(bio_err);
-                return 0;
+                BIO_closesocket(*sock);
+                *sock = INVALID_SOCKET;
+                goto out;
             }
             BIO_free(tmpbio);
         }