summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormbr <mbr@FreeBSD.org>2004-08-16 21:26:04 +0000
committermbr <mbr@FreeBSD.org>2004-08-16 21:26:04 +0000
commitc2d030ed8970881c2ca403866983d6d7cbb15ab3 (patch)
tree5933dec684ccf31506c4fc0ea5bf94b89e422039
parentdf7926e56986f042176266016acaf7f9950bebf8 (diff)
downloadFreeBSD-src-c2d030ed8970881c2ca403866983d6d7cbb15ab3.zip
FreeBSD-src-c2d030ed8970881c2ca403866983d6d7cbb15ab3.tar.gz
Recommit removed Rev. 1.40. This fix does solve a FPE with negative lease
time as described in the PR below. It seems that this patch should have been part of the vendor tree but got accidently missed in the 3.0.1 final version. It will definitly be part of 3.0.2 but until then it's a long way to go. Submitted by: ISC (Vendor) PR: bin/54517
-rw-r--r--contrib/isc-dhcp/client/dhclient.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/contrib/isc-dhcp/client/dhclient.c b/contrib/isc-dhcp/client/dhclient.c
index a942051..939bc7a 100644
--- a/contrib/isc-dhcp/client/dhclient.c
+++ b/contrib/isc-dhcp/client/dhclient.c
@@ -838,11 +838,15 @@ void dhcpack (packet)
/* If it wasn't specified by the server, calculate it. */
if (!client -> new -> renewal)
- client -> new -> renewal =
- client -> new -> expiry / 2;
+ client -> new -> renewal = client -> new -> expiry / 2 + 1;
+
+ if (client -> new -> renewal <= 0)
+ client -> new -> renewal = TIME_MAX;
/* Now introduce some randomness to the renewal time: */
- client -> new -> renewal = (((client -> new -> renewal + 3) * 3 / 4) +
+ if (client -> new -> renewal <= TIME_MAX / 3 - 3)
+ client -> new -> renewal =
+ (((client -> new -> renewal + 3) * 3 / 4) +
(random () % /* XXX NUMS */
((client -> new -> renewal + 3) / 4)));
@@ -861,14 +865,25 @@ void dhcpack (packet)
} else
client -> new -> rebind = 0;
- if (!client -> new -> rebind)
- client -> new -> rebind =
- (client -> new -> expiry * 7) / 8; /* XXX NUMS */
+ if (client -> new -> rebind <= 0) {
+ if (client -> new -> expiry <= TIME_MAX / 7)
+ client -> new -> rebind =
+ client -> new -> expiry * 7 / 8;
+ else
+ client -> new -> rebind =
+ client -> new -> expiry / 8 * 7;
+ }
/* Make sure our randomness didn't run the renewal time past the
rebind time. */
- if (client -> new -> renewal > client -> new -> rebind)
- client -> new -> renewal = (client -> new -> rebind * 3) / 4;
+ if (client -> new -> renewal > client -> new -> rebind) {
+ if (client -> new -> rebind <= TIME_MAX / 3)
+ client -> new -> renewal =
+ client -> new -> rebind * 3 / 4;
+ else
+ client -> new -> renewal =
+ client -> new -> rebind / 4 * 3;
+ }
client -> new -> expiry += cur_time;
/* Lease lengths can never be negative. */
OpenPOWER on IntegriCloud