From 9aa2afc3a57939e9cfc04926a2ffc20fb87286cf Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 18 Oct 2016 09:45:34 +0200 Subject: Curl_socket_check: add extra check to avoid integer overflow --- lib/select.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/select.c') 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 */ -- cgit v1.2.3