diff options
author | Daniel Stenberg <daniel@haxx.se> | 2021-09-14 13:03:06 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2021-09-14 13:03:06 +0200 |
commit | 7e3cd114e002462a3f8340bc9564368b75d06c67 (patch) | |
tree | 215688481a5151546acd55ff5235b8529a8f0fe0 /lib/multi.c | |
parent | 352b07fccec8f15e976f66a8d409751f7c49493c (diff) | |
download | curl-bagder/fix-fd_set-check.tar.gz |
curl_multi_fdset: make FD_SET() not operate on sockets out of rangebagder/fix-fd_set-check
The VALID_SOCK() macro was made to only check for FD_SETSIZE if curl was
built to use select(), even though the curl_multi_fdset() function
always and unconditionally uses FD_SET and needs the check.
Reported-by: 0xee on github
Fixes #7718
Diffstat (limited to 'lib/multi.c')
-rw-r--r-- | lib/multi.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/multi.c b/lib/multi.c index 85097816d..518ceb51f 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -1052,11 +1052,17 @@ CURLMcode curl_multi_fdset(struct Curl_multi *multi, for(i = 0; i< MAX_SOCKSPEREASYHANDLE; i++) { curl_socket_t s = CURL_SOCKET_BAD; - if((bitmap & GETSOCK_READSOCK(i)) && VALID_SOCK((sockbunch[i]))) { + if((bitmap & GETSOCK_READSOCK(i)) && VALID_SOCK(sockbunch[i])) { + if(!FDSET_SOCK(sockbunch[i])) + /* pretend it doesn't exist */ + continue; FD_SET(sockbunch[i], read_fd_set); s = sockbunch[i]; } - if((bitmap & GETSOCK_WRITESOCK(i)) && VALID_SOCK((sockbunch[i]))) { + if((bitmap & GETSOCK_WRITESOCK(i)) && VALID_SOCK(sockbunch[i])) { + if(!FDSET_SOCK(sockbunch[i])) + /* pretend it doesn't exist */ + continue; FD_SET(sockbunch[i], write_fd_set); s = sockbunch[i]; } |