#include "ares_setup.h"
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
*/
if (min_offset != -1)
{
- nextstop.tv_sec = min_offset/1000;
- nextstop.tv_usec = (min_offset%1000)*1000;
+ int ioffset = (min_offset > (long)INT_MAX) ? INT_MAX : (int)min_offset;
+
+ nextstop.tv_sec = ioffset/1000;
+ nextstop.tv_usec = (ioffset%1000)*1000;
if (!maxtv || ares__timedout(maxtv, &nextstop))
{