]> granicus.if.org Git - curl/commitdiff
Curl_socket_check: add extra check to avoid integer overflow
authorDaniel Stenberg <daniel@haxx.se>
Tue, 18 Oct 2016 07:45:34 +0000 (09:45 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 18 Oct 2016 07:45:34 +0000 (09:45 +0200)
lib/select.c

index abf55d878fd3e61318d43275f2d849b59f0fbf59..b9c110eb3b88695f6a6eb8f67484fc9e85fb733c 100644 (file)
@@ -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 */