e83fb1
diff -up dhcp-4.3.0a1/common/dispatch.c.interval dhcp-4.3.0a1/common/dispatch.c
e83fb1
--- dhcp-4.3.0a1/common/dispatch.c.interval	2013-12-20 13:51:14.385260622 +0100
e83fb1
+++ dhcp-4.3.0a1/common/dispatch.c	2013-12-20 13:51:14.493259116 +0100
e83fb1
@@ -343,7 +343,20 @@ void add_timeout (when, where, what, ref
bd413e
 	q->next  = timeouts;
bd413e
 	timeouts = q;
bd413e
 
bd413e
-	isc_interval_set(&interval, sec & DHCP_SEC_MAX, usec * 1000);
bd413e
+	/* isc_time_nowplusinterval() is not safe with 64-bit time_t and will
bd413e
+	 * return an error for sufficiently large intervals.  We have to limit
bd413e
+	 * the interval to INT_MAX or less to ensure the interval doesn't
bd413e
+	 * overflow 32 bits, since the returned isc_time_t fields are
bd413e
+	 * 32-bit unsigned ints.
bd413e
+	 *
bd413e
+	 * HACK: The 9 is a magic number of seconds, since some time may have
bd413e
+	 * gone by since the last call to gettimeofday() and the one in
bd413e
+	 * isc_time_nowplusinterval().
bd413e
+	 */
bd413e
+	if (sec > TIME_MAX)
bd413e
+		sec = TIME_MAX - 9;
bd413e
+
bd413e
+	isc_interval_set(&interval, sec, usec * 1000);
bd413e
 	status = isc_time_nowplusinterval(&expires, &interval);
bd413e
 	if (status != ISC_R_SUCCESS) {
bd413e
 		/*