isc_time_nowplusinterval() is not safe with 64-bit time_t (#662254, #789601)

This commit is contained in:
Jiri Popelka 2012-07-27 10:08:44 +02:00
parent 0371565b3f
commit bd413ec3f9
2 changed files with 33 additions and 1 deletions

View File

@ -0,0 +1,25 @@
diff -up dhcp-4.2.4/common/dispatch.c.foo dhcp-4.2.4/common/dispatch.c
--- dhcp-4.2.4/common/dispatch.c.foo 2012-07-26 21:31:43.875349675 -0500
+++ dhcp-4.2.4/common/dispatch.c 2012-07-26 21:39:14.961710319 -0500
@@ -324,7 +324,20 @@ void add_timeout (when, where, what, ref
q->next = timeouts;
timeouts = q;
- isc_interval_set(&interval, sec & DHCP_SEC_MAX, usec * 1000);
+ /* isc_time_nowplusinterval() is not safe with 64-bit time_t and will
+ * return an error for sufficiently large intervals. We have to limit
+ * the interval to INT_MAX or less to ensure the interval doesn't
+ * overflow 32 bits, since the returned isc_time_t fields are
+ * 32-bit unsigned ints.
+ *
+ * HACK: The 9 is a magic number of seconds, since some time may have
+ * gone by since the last call to gettimeofday() and the one in
+ * isc_time_nowplusinterval().
+ */
+ if (sec > TIME_MAX)
+ sec = TIME_MAX - 9;
+
+ isc_interval_set(&interval, sec, usec * 1000);
status = isc_time_nowplusinterval(&expires, &interval);
if (status != ISC_R_SUCCESS) {
/*

View File

@ -18,7 +18,7 @@
Summary: Dynamic host configuration protocol software
Name: dhcp
Version: 4.2.4
Release: 9.%{patchver}%{?dist}
Release: 10.%{patchver}%{?dist}
# NEVER CHANGE THE EPOCH on this package. The previous maintainer (prior to
# dcantrell maintaining the package) made incorrect use of the epoch and
# that's why it is at 12 now. It should have never been used, but it was.
@ -75,6 +75,7 @@ Patch40: dhcp-4.2.4-send_release.patch
Patch41: dhcp-4.2.3-P2-rfc5970-dhcpv6-options-for-network-boot.patch
Patch42: dhcp-4.2.4-failOverPeer.patch
Patch43: dhcp-4.2.4-P1-dhclient6-leases_semicolon_expected.patch
Patch44: dhcp-4.2.4-P1-interval.patch
BuildRequires: autoconf
BuildRequires: automake
@ -308,6 +309,9 @@ rm bind/bind.tar.gz
# Dhclient does not correctly parse zero-length options in dhclient6.leases (#633318)
%patch43 -p1 -b .dhclient6-leases_semicolon
# isc_time_nowplusinterval() is not safe with 64-bit time_t (#662254, #789601)
%patch44 -p1 -b .interval
pushd contrib
%{__chmod} -x 3.0b1-lease-convert dhclient-tz-exithook.sh ldap/dhcpd-conf-to-ldap
%{__chmod} -x sethostname.sh solaris.init
@ -575,6 +579,9 @@ fi
%changelog
* Fri Jul 27 2012 Jiri Popelka <jpopelka@redhat.com> - 12:4.2.4-10.P1
- isc_time_nowplusinterval() is not safe with 64-bit time_t (#662254, #789601)
* Fri Jul 27 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 12:4.2.4-9.P1
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild