summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorolszomal <Malgorzata.Olszowka@stunnel.org>2024-04-04 11:34:33 +0200
committerTomas Mraz <tomas@openssl.org>2024-04-10 09:26:05 +0200
commitb32efb6f018e660281c8648f8a20cd1f53b0b7de (patch)
tree18ccef2f28981c37cb68b8473418df95ee17924e
parente1b8d911b47f256d973fffccdf421a6368c2b87d (diff)
Fix socket descriptor checks on Windows
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)
-rw-r--r--crypto/bio/bio_lib.c8
-rw-r--r--crypto/bio/bio_sock.c4
2 files changed, 10 insertions, 2 deletions
diff --git a/crypto/bio/bio_lib.c b/crypto/bio/bio_lib.c
index c86b9ac198..10278496c1 100644
--- a/crypto/bio/bio_lib.c
+++ b/crypto/bio/bio_lib.c
@@ -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 */
diff --git a/crypto/bio/bio_sock.c b/crypto/bio/bio_sock.c
index 476cbcc5ce..6537a5062f 100644
--- a/crypto/bio/bio_sock.c
+++ b/crypto/bio/bio_sock.c
@@ -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;