Skip to content

Commit

Permalink
Fix socket descriptor checks on Windows
Browse files Browse the repository at this point in the history
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #24035)

(cherry picked from commit c89baf8)
  • Loading branch information
olszomal authored and t8m committed Apr 10, 2024
1 parent e9bf4c7 commit 77b8154
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 6 additions & 2 deletions crypto/bio/bio_lib.c
Expand Up @@ -965,8 +965,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 */

Expand Down
4 changes: 4 additions & 0 deletions crypto/bio/bio_sock.c
Expand Up @@ -435,7 +435,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;
Expand Down

0 comments on commit 77b8154

Please sign in to comment.