]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Close FILEs before overwriting NZF file (#38332)
authorMukund Sivaraman <muks@isc.org>
Fri, 16 Jan 2015 10:03:50 +0000 (15:33 +0530)
committerMukund Sivaraman <muks@isc.org>
Fri, 16 Jan 2015 10:07:09 +0000 (15:37 +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 3a9def7ec84eeb0a3d754c94a2ff51e9e7fc358b..4f12af4ae18a09bf2123a72794c17cdc3e0936c5 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]
+
 4033.  [bug]           Missing out of memory check in request.c:req_send.
                        [RT #38311]
 
index 8c322c18fbf7d1a80a4adfc0ca113ba2002aad12..f5060d7f4ae1da25f5bd8975a77de39a63013752 100644 (file)
@@ -9183,6 +9183,16 @@ ns_server_del_zone(ns_server_t *server, char *args, isc_buffer_t *text) {
                                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(tmpname, view->new_zone_file));
                } else {
@@ -9266,12 +9276,12 @@ ns_server_del_zone(ns_server_t *server, char *args, isc_buffer_t *text) {
                isc_task_endexclusive(server->task);
        if (ifp != NULL)
                isc_stdio_close(ifp);
-       if (ofp != NULL) {
+       if (ofp != NULL)
                isc_stdio_close(ofp);
+       if (tmpname != NULL) {
                isc_file_remove(tmpname);
-       }
-       if (tmpname != NULL)
                isc_mem_free(server->mctx, tmpname);
+       }
        if (raw != NULL)
                dns_zone_detach(&raw);
        if (zone != NULL)