summaryrefslogtreecommitdiffstats
path: root/lib/select.h
diff options
context:
space:
mode:
authorCurl Upstream <curl-library@cool.haxx.se>2020-12-09 06:38:24 (GMT)
committerBrad King <brad.king@kitware.com>2020-12-09 16:45:09 (GMT)
commit5aacc593a961fe9ee1427c03d18fba8947a9e33d (patch)
tree1eb7234820ce18ece5ae773015217f8135c9c08e /lib/select.h
parent7ceb56989f8ab3a4e1b1f2c48c9a0f382b85ec04 (diff)
downloadCMake-5aacc593a961fe9ee1427c03d18fba8947a9e33d.zip
CMake-5aacc593a961fe9ee1427c03d18fba8947a9e33d.tar.gz
CMake-5aacc593a961fe9ee1427c03d18fba8947a9e33d.tar.bz2
curl 2020-12-09 (e0528597)
Code extracted from: https://github.com/curl/curl.git at commit e052859759b34d0e05ce0f17244873e5cd7b457b (curl-7_74_0).
Diffstat (limited to 'lib/select.h')
-rw-r--r--lib/select.h17
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/select.h b/lib/select.h
index 95181f4..1350950 100644
--- a/lib/select.h
+++ b/lib/select.h
@@ -11,7 +11,7 @@
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
- * are also available at https://curl.haxx.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -94,12 +94,23 @@ int tpf_select_libcurl(int maxfds, fd_set* reads, fd_set* writes,
fd_set* excepts, struct timeval *tv);
#endif
-/* Winsock and TPF sockets are not in range [0..FD_SETSIZE-1], which
+/* TPF sockets are not in range [0..FD_SETSIZE-1], which
unfortunately makes it impossible for us to easily check if they're valid
+
+ With Winsock the valid range is [0..INVALID_SOCKET-1] according to
+ https://docs.microsoft.com/en-us/windows/win32/winsock/socket-data-type-2
*/
-#if defined(USE_WINSOCK) || defined(TPF)
+#if defined(TPF)
#define VALID_SOCK(x) 1
#define VERIFY_SOCK(x) Curl_nop_stmt
+#elif defined(USE_WINSOCK)
+#define VALID_SOCK(s) ((s) < INVALID_SOCKET)
+#define VERIFY_SOCK(x) do { \
+ if(!VALID_SOCK(x)) { \
+ SET_SOCKERRNO(WSAEINVAL); \
+ return -1; \
+ } \
+} while(0)
#else
#define VALID_SOCK(s) (((s) >= 0) && ((s) < FD_SETSIZE))
#define VERIFY_SOCK(x) do { \