]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
bio: check for valid socket when closing
authorPauli <pauli@openssl.org>
Mon, 28 Jun 2021 22:01:13 +0000 (08:01 +1000)
committerPauli <pauli@openssl.org>
Wed, 30 Jun 2021 03:55:09 +0000 (13:55 +1000)
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)

crypto/bio/bio_sock2.c

index f13f20148bbebd2a83feb23a019686ab081b0d28..b6c95913ce6d050b2bf53acef933aed91d841e73 100644 (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;
 }