On BIO_listen or BIO_sock_info failure we close the socket but leave
accept_sock and b->num pointing at the old fd. Later cleanup can double
close.
Set both to INVALID_SOCKET immediately after BIO_closesocket.
Signed-off-by: Joshua Rogers <MegaManSec@users.noreply.github.com>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28904)
(cherry picked from commit
1c4f7b10358b79a0b33619187caa2b7e3bdb6e7a)
BIO_ADDRINFO_address(c->addr_iter),
c->bind_mode)) {
BIO_closesocket(c->accept_sock);
+ c->accept_sock = (int)INVALID_SOCKET;
+ b->num = (int)INVALID_SOCKET;
goto exit_loop;
}
}
if (!BIO_sock_info(c->accept_sock, BIO_SOCK_INFO_ADDRESS,
&info)) {
BIO_closesocket(c->accept_sock);
+ c->accept_sock = (int)INVALID_SOCKET;
+ b->num = (int)INVALID_SOCKET;
goto exit_loop;
}
}