bio: check for valid socket when closing

Fixes coverity 271258 Improper use of negative value (NEGATIVE_RETURNS)

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15943)
This commit is contained in:
Pauli 2021-06-29 08:01:13 +10:00
parent 01fb4bff9b
commit 196feb18de

View File

@ -335,7 +335,7 @@ int BIO_accept_ex(int accept_sock, BIO_ADDR *addr_, int options)
*/
int BIO_closesocket(int sock)
{
if (closesocket(sock) < 0)
if (sock < 0 || closesocket(sock) < 0)
return 0;
return 1;
}