]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
- Attempting to write a new lease file to replace a corrupt (due to
authorDavid Hankins <dhankins@isc.org>
Wed, 19 Jul 2006 16:44:47 +0000 (16:44 +0000)
committerDavid Hankins <dhankins@isc.org>
Wed, 19 Jul 2006 16:44:47 +0000 (16:44 +0000)
  encountering non-retryable errors during writing) lease file should
  no longer result in an infinite recursion. [ISC-Bugs #16265]

RELNOTES
server/db.c

index 6b7aed3fb1154a101f6b9fa31d45b4139e01e507..59675213144aaeeeffc9907783a74dbfd3b8b337 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -168,6 +168,10 @@ and for prodding me into improving it.
 - Abandoned or dissociated (err condition) leases now remove any related
   dynamic dns bindings.  Thanks to a patch from Patrick Schoo.
 
+- 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.
+
                        Changes since 3.0.4rc1
 
 - The dhcp-options.5 manpage was updated to correct indentation errors
index 7431fa7d78e406da28a1d29c8cab11b720d03643..004e840bcbffaf063fb2fc5ab1303d2297d6cb99 100644 (file)
@@ -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;