]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Close FILEs before overwriting NZF file (#38332)
authorMukund Sivaraman <muks@isc.org>
Fri, 16 Jan 2015 09:50:45 +0000 (15:20 +0530)
committerMukund Sivaraman <muks@isc.org>
Fri, 16 Jan 2015 09:53:11 +0000 (15:23 +0530)
Based on a patch sent in by Tony Finch <dot@dotat.at>.

CHANGES
bin/named/server.c

diff --git a/CHANGES b/CHANGES
index 835cfd09d42d25243c88a5561187b8747ed8e8a9..0772e483a6f0a484ce7174f3a933b1399099fcab 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+4035.  [bug]           Close temporary and NZF FILE pointers before moving
+                       the former into the latter's place, as required on
+                       Windows. [RT #38332]
+
 4034.  [func]          When added, negative trust anchors (NTA) are now
                        saved to files (viewname.nta), in order to
                        persist across restarts of the named server.
index b8a783207b467180795a11a7a8c3ef59ae8e61d1..4876c6ef809e42b2a974e86625ee7c344e996655 100644 (file)
@@ -9274,6 +9274,16 @@ nzf_remove(const char *nzfile, const char *viewname, const char *zonename) {
                                result = isc_stdio_read(buf, 1, 1024, ifp, &n);
                        }
 
+                       /*
+                        * Close files before overwriting the nzfile
+                        * with the temporary file as it's necessary on
+                        * some platforms (win32).
+                        */
+                       (void) isc_stdio_close(ifp);
+                       ifp = NULL;
+                       (void) isc_stdio_close(ofp);
+                       ofp = NULL;
+
                        /* Move temporary into place */
                        CHECK(isc_file_rename(tmp, nzfile));
                } else {
@@ -9287,9 +9297,9 @@ nzf_remove(const char *nzfile, const char *viewname, const char *zonename) {
 
  cleanup:
        if (ifp != NULL)
-               isc_stdio_close(ifp);
+               (void) isc_stdio_close(ifp);
        if (ofp != NULL)
-               isc_stdio_close(ofp);
+               (void) isc_stdio_close(ofp);
 
        return (result);
 }