FreeBSD Bugzilla – Attachment 182372 Details for
Bug 218980
dhclient incorrectly handles very long lease times, setting expiry in the past
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Second patch for dhclient.c
dhclient.c.patch (text/plain), 3.38 KB, created by
Nick Hibma
on 2017-05-07 18:45:39 UTC
(
hide
)
Description:
Second patch for dhclient.c
Filename:
MIME Type:
Creator:
Nick Hibma
Created:
2017-05-07 18:45:39 UTC
Size:
3.38 KB
patch
obsolete
>Index: dhclient.c >=================================================================== >--- dhclient.c (revision 317659) >+++ dhclient.c (working copy) >@@ -107,7 +107,11 @@ > */ > #define ASSERT_STATE(state_is, state_shouldbe) {} > >-#define TIME_MAX 2147483647 >+/* >+ * We need to check that the expiry, renewal and rebind times are not beyond >+ * the end of time (~2038 when a 32-bit time_t is being used). >+ */ >+#define TIME_MAX ((((time_t) 1 << (sizeof(time_t) * CHAR_BIT - 2)) - 1) * 2 + 1) > > int log_priority; > int no_daemon; >@@ -762,17 +766,17 @@ > else > ip->client->new->expiry = default_lease_time; > /* A number that looks negative here is really just very large, >- because the lease expiry offset is unsigned. */ >- if (ip->client->new->expiry < 0) >- ip->client->new->expiry = TIME_MAX; >+ because the lease expiry offset is unsigned. Also make sure that >+ the addition of cur_time below does not overflow a 32 bit time_t. */ >+ if (ip->client->new->expiry < 0 || ip->client->new->expiry > TIME_MAX - cur_time) >+ ip->client->new->expiry = TIME_MAX - cur_time; > /* XXX should be fixed by resetting the client state */ > if (ip->client->new->expiry < 60) > ip->client->new->expiry = 60; > > /* Unless overridden in the config, take the server-provided renewal >- * time if there is one; otherwise figure it out according to the spec. >- * Also make sure the renewal time does not exceed the expiry time. >- */ >+ time if there is one; otherwise figure it out according to the spec. >+ Also make sure the renewal time does not exceed the expiry time. */ > if (ip->client->config->default_actions[DHO_DHCP_RENEWAL_TIME] == > ACTION_SUPERSEDE) > ip->client->new->renewal = getULong( >@@ -782,7 +786,8 @@ > ip->client->new->options[DHO_DHCP_RENEWAL_TIME].data); > else > ip->client->new->renewal = ip->client->new->expiry / 2; >- if (ip->client->new->renewal > ip->client->new->expiry / 2) >+ if (ip->client->new->renewal < 0 || >+ ip->client->new->renewal > ip->client->new->expiry / 2) > ip->client->new->renewal = ip->client->new->expiry / 2; > > /* Same deal with the rebind time. */ >@@ -794,20 +799,15 @@ > ip->client->new->rebind = getULong( > ip->client->new->options[DHO_DHCP_REBINDING_TIME].data); > else >- ip->client->new->rebind = ip->client->new->renewal * 7 / 4; >- if (ip->client->new->rebind > ip->client->new->renewal * 7 / 4) >- ip->client->new->rebind = ip->client->new->renewal * 7 / 4; >+ ip->client->new->rebind = ip->client->new->renewal / 4 * 7; >+ if (ip->client->new->rebind < 0 || >+ ip->client->new->rebind > ip->client->new->renewal / 4 * 7) >+ ip->client->new->rebind = ip->client->new->renewal / 4 * 7; > >- ip->client->new->expiry += cur_time; >- /* Lease lengths can never be negative. */ >- if (ip->client->new->expiry < cur_time) >- ip->client->new->expiry = TIME_MAX; >- ip->client->new->renewal += cur_time; >- if (ip->client->new->renewal < cur_time) >- ip->client->new->renewal = TIME_MAX; >- ip->client->new->rebind += cur_time; >- if (ip->client->new->rebind < cur_time) >- ip->client->new->rebind = TIME_MAX; >+ /* Convert the time offsets into seconds-since-the-epoch */ >+ ip->client->new->expiry += cur_time; >+ ip->client->new->renewal += cur_time; >+ ip->client->new->rebind += cur_time; > > bind_lease(ip); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 218980
:
182197
|
182240
|
182241
| 182372 |
182373
|
182375
|
182376