diff options
author | 2014-05-18 15:17:50 +0000 | |
---|---|---|
committer | 2014-05-18 15:17:50 +0000 | |
commit | c43a89b200ce6234a10ac94fd25592950043483f (patch) | |
tree | 651eb27430e01483522e4a8246e8a0d50a9d9b32 | |
parent | sync (diff) | |
download | wireguard-openbsd-c43a89b200ce6234a10ac94fd25592950043483f.tar.xz wireguard-openbsd-c43a89b200ce6234a10ac94fd25592950043483f.zip |
Don't add a lease to the leases TAILQ more than once. It tends to
make writing out the leases file go into an infinite loop until
/var is full.
Reported by Roman Gorelov via bugs@
Fix tested & ok stsp@ uwe@
-rw-r--r-- | sbin/dhclient/dhclient.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index 50356a086c8..250c71b439e 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.306 2014/05/12 18:50:02 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.307 2014/05/18 15:17:50 krw Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -802,7 +802,8 @@ bind_lease(void) struct in_addr gateway, mask; struct option_data *options, *opt; struct client_lease *lease, *pl; - + int seen; + /* * If it's been here before (e.g. static lease), clear out any * old resolv_conf. @@ -900,14 +901,17 @@ newlease: free_client_lease(lease); /* Remove previous dynamic lease(es) for this address. */ + seen = 0; TAILQ_FOREACH_SAFE(lease, &client->leases, next, pl) { if (lease->is_static) break; - if (client->active != lease && lease->address.s_addr == + if (client->active == lease) + seen = 1; + else if (lease->address.s_addr == client->active->address.s_addr) free_client_lease(lease); } - if (!client->active->is_static) + if (!client->active->is_static && !seen) TAILQ_INSERT_HEAD(&client->leases, client->active, next); client->state = S_BOUND; |