]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix a memory leak in sctp code
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Sun, 4 Jan 2026 18:52:15 +0000 (19:52 +0100)
committerNeil Horman <nhorman@openssl.org>
Tue, 6 Jan 2026 12:56:14 +0000 (07:56 -0500)
There is a memory leak of the addrinfo struct when
`./openssl s_server -dtls -sctp -accept 127.0.0.1:4433`
is used, but `sysctl -w net.sctp.auth_enable=1`
is not done before.
Additionally this fixes an oversight, when
`./openssl s_client -dtls -sctp -connect localhost:4433`
is used to connect to above server.
The first connect attempt is to IPv6 ::1, which might fail,
but the second attempt might still succeed, so continue to
try all addesses even when the SCTP socket fails for one of them.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Yang <paulyang.inf@gmail.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29541)

apps/lib/s_socket.c

index 976728a423321af1e64441ab873343089e160cb7..5a6d938edf6c6bf91912549a3b0b123d1d26070e 100644 (file)
@@ -156,7 +156,7 @@ int init_client(int *sock, const char *host, const char *port,
             if (tmpbio == NULL) {
                 BIO_closesocket(*sock);
                 *sock = INVALID_SOCKET;
-                goto out;
+                continue;
             }
             BIO_free(tmpbio);
         }
@@ -380,6 +380,7 @@ int do_server(int *accept_sock, const char *host, const char *port,
         BIO *tmpbio = BIO_new_dgram_sctp(asock, BIO_NOCLOSE);
 
         if (tmpbio == NULL) {
+            BIO_ADDRINFO_free(res);
             BIO_closesocket(asock);
             ERR_print_errors(bio_err);
             goto end;