summaryrefslogtreecommitdiff
path: root/sbin/dhclient/dhclient.c
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2014-11-04 04:03:11 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2014-11-04 04:03:11 +0000
commitcefb1e50d4e57d7713435d89fd8813efc97c6e0f (patch)
tree9bb432e71e4bdcfdc1335b29089532f203dd8bbe /sbin/dhclient/dhclient.c
parente4c4620ffe8623533ec6947ff4bf36fbfce7dc3e (diff)
Of the 14 occurances of free_client_lease() only 2 deal with leases
that might be in the client->leases TAILQ. So don't traverse said TAILQ in free_client_lease() trying see if the lease should be TAILQ_REMOVE()'d. Instead use TAILQ_REMOVE() in the two places (one of which is dubious) where it might be relevant. Be careful not to TAILQ_REMOVE() a static lease.
Diffstat (limited to 'sbin/dhclient/dhclient.c')
-rw-r--r--sbin/dhclient/dhclient.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index e6f7ab3ae90..7940c26c5af 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.328 2014/11/04 01:20:27 guenther Exp $ */
+/* $OpenBSD: dhclient.c,v 1.329 2014/11/04 04:03:10 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -915,8 +915,10 @@ newlease:
if (client->active == lease)
seen = 1;
else if (lease->expiry <= cur_time || lease->address.s_addr ==
- client->active->address.s_addr)
+ client->active->address.s_addr) {
+ TAILQ_REMOVE(&client->leases, lease, next);
free_client_lease(lease);
+ }
}
if (!client->active->is_static && !seen)
TAILQ_INSERT_HEAD(&client->leases, client->active, next);
@@ -1146,7 +1148,12 @@ dhcpnak(struct in_addr client_addr, struct option_data *options, char *info)
note("%s", info);
- free_client_lease(client->active);
+ /* XXX Do we really want to remove a NAK'd lease from the database? */
+ if (!client->active->is_static) {
+ TAILQ_REMOVE(&client->leases, client->active, next);
+ free_client_lease(client->active);
+ }
+
client->active = NULL;
/* Stop sending DHCPREQUEST packets. */
@@ -1580,18 +1587,12 @@ make_decline(struct client_lease *lease)
void
free_client_lease(struct client_lease *lease)
{
- struct client_lease *lp, *pl;
int i;
/* Static leases are forever. */
if (lease->is_static)
return;
- TAILQ_FOREACH_SAFE(lp, &client->leases, next, pl) {
- if (lease == lp)
- TAILQ_REMOVE(&client->leases, lp, next);
- }
-
if (lease->server_name)
free(lease->server_name);
if (lease->filename)