Commit c1915935 authored by Mark Andrews's avatar Mark Andrews

4429. [bug] Address potential use after free on fclose() error.

                        [RT #42976]
parent c4153b55
4429. [bug] Address potential use after free on fclose() error.
[RT #42976]
4428. [bug] The "test dispatch getnext" unit test could fail
in a threaded build. [RT #42979]
......
......@@ -1421,7 +1421,7 @@ main(int argc, char *argv[]) {
if (result == ISC_R_SUCCESS) {
isc_mem_stats(ns_g_mctx, fp);
isc_mutex_stats(fp);
isc_stdio_close(fp);
(void) isc_stdio_close(fp);
}
}
isc_mem_destroy(&ns_g_mctx);
......
......@@ -6268,7 +6268,10 @@ generate_session_key(const char *filename, const char *keynamestr,
(char*) isc_buffer_base(&key_txtbuffer));
CHECK(isc_stdio_flush(fp));
CHECK(isc_stdio_close(fp));
result = isc_stdio_close(fp);
fp = NULL;
if (result != ISC_R_SUCCESS)
goto cleanup;
dst_key_free(&key);
......@@ -10750,7 +10753,7 @@ nzf_append(dns_view_t *view, const cfg_obj_t *zconfig) {
cfg_printx(zconfig, CFG_PRINTER_ONELINE, dumpzone, fp);
CHECK(isc_stdio_write(";\n", 2, 1, fp, NULL));
CHECK(isc_stdio_flush(fp));
CHECK(isc_stdio_close(fp));
result = isc_stdio_close(fp);
fp = NULL;
cleanup:
......@@ -10795,15 +10798,17 @@ nzf_writeconf(const cfg_obj_t *config, dns_view_t *view) {
cfg_printx(config, CFG_PRINTER_ONELINE, dumpzone, fp);
CHECK(isc_stdio_flush(fp));
CHECK(isc_stdio_close(fp));
result = isc_stdio_close(fp);
fp = NULL;
if (result != ISC_R_SUCCESS)
goto cleanup;
CHECK(isc_file_rename(tmp, view->new_zone_file));
return (result);
cleanup:
if (fp != NULL)
(void) isc_stdio_close(fp);
isc_file_remove(tmp);
(void)isc_stdio_close(fp);
(void)isc_file_remove(tmp);
return (result);
}
......@@ -11343,7 +11348,7 @@ do_addzone(ns_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
goto cleanup;
}
isc_stdio_close(fp);
(void)isc_stdio_close(fp);
fp = NULL;
#else /* HAVE_LMDB */
/* Make sure we can open the NZD database */
......@@ -11435,7 +11440,7 @@ do_addzone(ns_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
#ifndef HAVE_LMDB
if (fp != NULL)
(void) isc_stdio_close(fp);
(void)isc_stdio_close(fp);
#else /* HAVE_LMDB */
if (txn != NULL)
(void) nzd_close(&txn, ISC_FALSE);
......@@ -11494,7 +11499,7 @@ do_modzone(ns_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
TCHECK(putstr(text, isc_result_totext(result)));
goto cleanup;
}
isc_stdio_close(fp);
(void)isc_stdio_close(fp);
fp = NULL;
#else /* HAVE_LMDB */
/* Make sure we can open the NZD database */
......@@ -11636,7 +11641,7 @@ do_modzone(ns_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
#ifndef HAVE_LMDB
if (fp != NULL)
(void) isc_stdio_close(fp);
(void)isc_stdio_close(fp);
#else /* HAVE_LMDB */
if (txn != NULL)
(void) nzd_close(&txn, ISC_FALSE);
......
......@@ -2197,6 +2197,9 @@ dns_view_saventa(dns_view_t *view) {
if (result == ISC_R_NOTFOUND) {
removefile = ISC_TRUE;
result = ISC_R_SUCCESS;
} else if (result == ISC_R_SUCCESS) {
result = isc_stdio_close(fp);
fp = NULL;
}
cleanup:
......@@ -2204,7 +2207,7 @@ dns_view_saventa(dns_view_t *view) {
dns_ntatable_detach(&ntatable);
if (fp != NULL)
isc_stdio_close(fp);
(void)isc_stdio_close(fp);
/* Don't leave half-baked NTA save files lying around. */
if (result != ISC_R_SUCCESS || removefile)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment