diff options
author | David Hankins <dhankins@isc.org> | 2006-07-19 16:44:47 +0000 |
---|---|---|
committer | David Hankins <dhankins@isc.org> | 2006-07-19 16:44:47 +0000 |
commit | e77c575fc4c8c2a5b53b4008df5bd6709855c4a0 (patch) | |
tree | bf9b535ca8c36397ab0aa3dc0125d5c944d0ab17 /server/db.c | |
parent | 87578987655f1a95d7877cb5136e2b552944e1c6 (diff) | |
download | isc-dhcp-e77c575fc4c8c2a5b53b4008df5bd6709855c4a0.tar.gz |
- Attempting to write a new lease file to replace a corrupt (due to
encountering non-retryable errors during writing) lease file should
no longer result in an infinite recursion. [ISC-Bugs #16265]
Diffstat (limited to 'server/db.c')
-rw-r--r-- | server/db.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/server/db.c b/server/db.c index 7431fa7d..004e840b 100644 --- a/server/db.c +++ b/server/db.c @@ -34,7 +34,7 @@ #ifndef lint static char copyright[] = -"$Id: db.c,v 1.73 2006/06/06 16:35:18 dhankins Exp $ Copyright (c) 2004-2006 Internet Systems Consortium. All rights reserved.\n"; +"$Id: db.c,v 1.74 2006/07/19 16:44:47 dhankins Exp $ Copyright (c) 2004-2006 Internet Systems Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -794,11 +794,14 @@ int new_lease_file () char backfname [512]; TIME t; int db_fd; + int db_validity; FILE *new_db_file; /* Make a temporary lease file... */ GET_TIME (&t); + db_validity = lease_file_is_corrupt; + /* %Audit% Truncated filename causes panic. %2004.06.17,Safe% * This should never happen since the path is a configuration * variable from build-time or command-line. But if it should, @@ -835,6 +838,11 @@ int new_lease_file () if (errno != 0) goto fail; + /* At this point we have a new lease file that, so far, could not + * be described as either corrupt nor valid. + */ + lease_file_is_corrupt = 0; + /* Write out all the leases that we know of... */ counting = 0; if (!write_leases ()) @@ -881,11 +889,10 @@ int new_lease_file () } counting = 1; - lease_file_is_corrupt = 0; return 1; fail: - lease_file_is_corrupt = 1; + lease_file_is_corrupt = db_validity; fdfail: unlink (newfname); return 0; |