aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2016-10-18 09:45:34 +0200
committerDaniel Stenberg <daniel@haxx.se>2016-10-18 09:45:34 +0200
commit9aa2afc3a57939e9cfc04926a2ffc20fb87286cf (patch)
treebf872208d50c9b0bd5e6a2c9b67a71a38977c41c
parentd18c5464541185e43a3fbaae5a36b4ce75343d79 (diff)
Curl_socket_check: add extra check to avoid integer overflow
-rw-r--r--lib/select.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/select.c b/lib/select.c
index abf55d878..b9c110eb3 100644
--- a/lib/select.c
+++ b/lib/select.c
@@ -165,6 +165,12 @@ int Curl_socket_check(curl_socket_t readfd0, /* two sockets to read from */
int r;
int ret;
+#if SIZEOF_LONG != SIZEOF_INT
+ /* wrap-around precaution */
+ if(timeout_ms >= INT_MAX)
+ timeout_ms = INT_MAX;
+#endif
+
if((readfd0 == CURL_SOCKET_BAD) && (readfd1 == CURL_SOCKET_BAD) &&
(writefd == CURL_SOCKET_BAD)) {
/* no sockets, just wait */