From: Tomas Mraz Date: Thu, 18 Jul 2024 09:01:00 +0000 (+0200) Subject: Avoid leaking *ba_ret on reconnections X-Git-Tag: openssl-3.3.2~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d4ed29730c296a41c720e84ea66af0c05593d6e6;p=thirdparty%2Fopenssl.git Avoid leaking *ba_ret on reconnections Also fixes Coverity 1604639 There is no point in checking ba_ret as it can never be NULL. Reviewed-by: Tom Cosgrove Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/24931) (cherry picked from commit 4fa9d1f40fc85d8c70c93168dc812217db349359) --- diff --git a/apps/lib/s_socket.c b/apps/lib/s_socket.c index 24e79425695..f7454053cfe 100644 --- a/apps/lib/s_socket.c +++ b/apps/lib/s_socket.c @@ -84,9 +84,6 @@ int init_client(int *sock, const char *host, const char *port, int ret; int options = 0; - if (tfo && ba_ret != NULL) - *ba_ret = NULL; - if (BIO_sock_init() != 1) return 0; diff --git a/apps/s_client.c b/apps/s_client.c index 78a44755cb5..6a124e0a19a 100644 --- a/apps/s_client.c +++ b/apps/s_client.c @@ -2167,6 +2167,9 @@ int s_client_main(int argc, char **argv) if (tfo) BIO_printf(bio_c_out, "Connecting via TFO\n"); re_start: + /* peer_addr might be set from previous connections */ + BIO_ADDR_free(peer_addr); + peer_addr = NULL; if (init_client(&sock, host, port, bindhost, bindport, socket_family, socket_type, protocol, tfo, !isquic, &peer_addr) == 0) { BIO_printf(bio_err, "connect:errno=%d\n", get_last_socket_error());