]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix socket descriptor checks on Windows
authorolszomal <Malgorzata.Olszowka@stunnel.org>
Thu, 4 Apr 2024 09:34:33 +0000 (11:34 +0200)
committerTomas Mraz <tomas@openssl.org>
Wed, 10 Apr 2024 07:26:05 +0000 (09:26 +0200)
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24035)

(cherry picked from commit c89baf871030c811ba316ccbdcea26c294f605ae)

crypto/bio/bio_lib.c
crypto/bio/bio_sock.c

index c86b9ac198cab0c6e967cc3b353ea7d195cbb1a2..10278496c1148a86621d1661837c4e8cb07451a9 100644 (file)
@@ -869,8 +869,12 @@ static int bio_wait(BIO *bio, time_t max_time, unsigned int nap_milliseconds)
         return 1;
 
 #ifndef OPENSSL_NO_SOCK
-    if (BIO_get_fd(bio, &fd) > 0 && fd < FD_SETSIZE)
-        return BIO_socket_wait(fd, BIO_should_read(bio), max_time);
+    if (BIO_get_fd(bio, &fd) > 0) {
+        int ret = BIO_socket_wait(fd, BIO_should_read(bio), max_time);
+
+        if (ret != -1)
+            return ret;
+    }
 #endif
     /* fall back to polling since no sockets are available */
 
index 476cbcc5cef16103ebc4cbbc2a1056259b794869..6537a5062fe818c96be4ffeb46e75b2dadb0e9f9 100644 (file)
@@ -396,7 +396,11 @@ int BIO_socket_wait(int fd, int for_read, time_t max_time)
     struct timeval tv;
     time_t now;
 
+#ifdef _WIN32
+    if ((SOCKET)fd == INVALID_SOCKET)
+#else
     if (fd < 0 || fd >= FD_SETSIZE)
+#endif
         return -1;
     if (max_time == 0)
         return 1;