#include "curl_setup.h"
+#include <limits.h>
+
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#elif defined(HAVE_UNISTD_H)
#include "urldata.h"
#include "connect.h"
#include "select.h"
+#include "timeval.h"
#include "warnless.h"
/* Convenience local macros */
int r;
int ret;
-#if SIZEOF_TIME_T != SIZEOF_INT
- /* wrap-around precaution */
- if(timeout_ms >= INT_MAX)
+ /* prevent overflow. timeout_ms is typecast to time_t and int. */
+#if TIMEDIFF_T_MAX > INT_MAX
+ if(timeout_ms > INT_MAX)
timeout_ms = INT_MAX;
#endif
+#if INT_MAX > TIME_T_MAX
+ if(timeout_ms > (int)TIME_T_MAX)
+ timeout_ms = (int)TIME_T_MAX;
+#endif
if((readfd0 == CURL_SOCKET_BAD) && (readfd1 == CURL_SOCKET_BAD) &&
(writefd == CURL_SOCKET_BAD)) {