diff --git a/CHANGES b/CHANGES index 983a9ae2ff..f5fa916cec 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +3866. [bug] Named could die on disk full in generate_session_key. + [RT #36119] + 3865. [test] Improved testability of the red-black tree implementation and added unit tests. [RT #35904] diff --git a/bin/named/server.c b/bin/named/server.c index 3c62b9b1aa..789ca8a1ca 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -5097,8 +5097,8 @@ generate_session_key(const char *filename, const char *keynamestr, (int) isc_buffer_usedlength(&key_txtbuffer), (char*) isc_buffer_base(&key_txtbuffer)); - RUNTIME_CHECK(isc_stdio_flush(fp) == ISC_R_SUCCESS); - RUNTIME_CHECK(isc_stdio_close(fp) == ISC_R_SUCCESS); + CHECK(isc_stdio_flush(fp)); + CHECK(isc_stdio_close(fp)); dst_key_free(&key); @@ -5111,6 +5111,11 @@ generate_session_key(const char *filename, const char *keynamestr, NS_LOGMODULE_SERVER, ISC_LOG_ERROR, "failed to generate session key " "for dynamic DNS: %s", isc_result_totext(result)); + if (fp != NULL) { + if (isc_file_exists(filename)) + (void)isc_file_remove(filename); + (void)isc_stdio_close(fp); + } if (tsigkey != NULL) dns_tsigkey_detach(&tsigkey); if (key != NULL)