]> 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 17:00:35 +0000 (18:00 +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)

(cherry picked from commit 3005b9bc8691c570f3f51c25219b7ba79a064d83)

apps/lib/s_socket.c

index a5b15792e18182f79c9143fb36f69b6ca33ecf6a..c6254a0a1c71dd5f49f3378f709a3104ab5b1309 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);
         }