From: Mukund Sivaraman Date: Fri, 16 Jan 2015 09:50:45 +0000 (+0530) Subject: Close FILEs before overwriting NZF file (#38332) X-Git-Tag: v9.11.0a1~1105 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=f91c369b4ac84fad07e3106c5c00a15d87250d1e;p=thirdparty%2Fbind9.git Close FILEs before overwriting NZF file (#38332) Based on a patch sent in by Tony Finch . --- diff --git a/CHANGES b/CHANGES index 835cfd09d42..0772e483a6f 100644 --- 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. diff --git a/bin/named/server.c b/bin/named/server.c index b8a783207b4..4876c6ef809 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -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); }