mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 08:08:50 -05:00
Winsock sockets are not in range 0..FD_SETSIZE.
Shouldn't Curl_select() use curl_socket_t ?
This commit is contained in:
parent
03e7b7c95f
commit
2b403db811
10
lib/select.c
10
lib/select.c
@ -33,6 +33,12 @@
|
|||||||
|
|
||||||
#include "select.h"
|
#include "select.h"
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#define VALID_SOCK(s) (1) /* Win-sockets are not in range [0..FD_SETSIZE> */
|
||||||
|
#else
|
||||||
|
#define VALID_SOCK(s) ((s) >= 0) && ((s) < FD_SETSIZE))
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is an internal function used for waiting for read or write
|
* This is an internal function used for waiting for read or write
|
||||||
* events on single file descriptors. It attempts to replace select()
|
* events on single file descriptors. It attempts to replace select()
|
||||||
@ -104,7 +110,7 @@ int Curl_select(int readfd, int writefd, int timeout_ms)
|
|||||||
|
|
||||||
FD_ZERO(&fds_read);
|
FD_ZERO(&fds_read);
|
||||||
if (readfd != CURL_SOCKET_BAD) {
|
if (readfd != CURL_SOCKET_BAD) {
|
||||||
if ((readfd < 0) || (readfd >= FD_SETSIZE)) {
|
if (!VALID_SOCK(readfd)) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -115,7 +121,7 @@ int Curl_select(int readfd, int writefd, int timeout_ms)
|
|||||||
|
|
||||||
FD_ZERO(&fds_write);
|
FD_ZERO(&fds_write);
|
||||||
if (writefd != CURL_SOCKET_BAD) {
|
if (writefd != CURL_SOCKET_BAD) {
|
||||||
if ((writefd < 0) || (writefd >= FD_SETSIZE)) {
|
if (!VALID_SOCK(writefd)) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user