2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-02 15:45:25 +00:00

Close FILEs before overwriting NZF file (#38332)

Based on a patch sent in by Tony Finch <dot@dotat.at>.
This commit is contained in:
Mukund Sivaraman
2015-01-16 15:20:45 +05:30
parent dddceb7732
commit f91c369b4a
2 changed files with 16 additions and 2 deletions

View File

@@ -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 4034. [func] When added, negative trust anchors (NTA) are now
saved to files (viewname.nta), in order to saved to files (viewname.nta), in order to
persist across restarts of the named server. persist across restarts of the named server.

View 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); 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 */ /* Move temporary into place */
CHECK(isc_file_rename(tmp, nzfile)); CHECK(isc_file_rename(tmp, nzfile));
} else { } else {
@@ -9287,9 +9297,9 @@ nzf_remove(const char *nzfile, const char *viewname, const char *zonename) {
cleanup: cleanup:
if (ifp != NULL) if (ifp != NULL)
isc_stdio_close(ifp); (void) isc_stdio_close(ifp);
if (ofp != NULL) if (ofp != NULL)
isc_stdio_close(ofp); (void) isc_stdio_close(ofp);
return (result); return (result);
} }