Attempt to fix a bug which throws away valid static leases

when parsing dhclient.leases. PR bin/9405.
This commit is contained in:
mellon 2003-10-24 05:19:31 +00:00
parent 3600060b1e
commit bc6c928df7
1 changed files with 8 additions and 6 deletions

View File

@ -43,7 +43,7 @@
#ifndef lint #ifndef lint
static char copyright[] = static char copyright[] =
"$Id: clparse.c,v 1.4 2002/06/11 14:00:00 drochner Exp $ Copyright (c) 1996-2001 The Internet Software Consortium. All rights reserved.\n"; "$Id: clparse.c,v 1.5 2003/10/24 05:19:31 mellon Exp $ Copyright (c) 1996-2001 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
@ -834,7 +834,7 @@ void parse_client_lease_statement (cfile, is_static)
struct parse *cfile; struct parse *cfile;
int is_static; int is_static;
{ {
struct client_lease *lease, *lp, *pl; struct client_lease *lease, *lp, *pl, *next;
struct interface_info *ip = (struct interface_info *)0; struct interface_info *ip = (struct interface_info *)0;
int token; int token;
const char *val; const char *val;
@ -894,17 +894,19 @@ void parse_client_lease_statement (cfile, is_static)
lease list looking for a lease with the same address, and lease list looking for a lease with the same address, and
if we find it, toss it. */ if we find it, toss it. */
pl = (struct client_lease *)0; pl = (struct client_lease *)0;
for (lp = client -> leases; lp; lp = lp -> next) { for (lp = client -> leases; lp; lp = next) {
next = lp -> next;
if (lp -> address.len == lease -> address.len && if (lp -> address.len == lease -> address.len &&
!memcmp (lp -> address.iabuf, lease -> address.iabuf, !memcmp (lp -> address.iabuf, lease -> address.iabuf,
lease -> address.len)) { lease -> address.len)) {
if (pl) if (pl)
pl -> next = lp -> next; pl -> next = next;
else else
client -> leases = lp -> next; client -> leases = next;
destroy_client_lease (lp); destroy_client_lease (lp);
break; break;
} } else
pl = lp;
} }
/* If this is a preloaded lease, just put it on the list of recorded /* If this is a preloaded lease, just put it on the list of recorded