Check that FILE_STREAM(channel) is not already closed

isc_log_closefilelogs can also close log files.  isc_log_doit failed
to check if the file handle was still valid before closing it.
This commit is contained in:
Mark Andrews 2024-06-19 17:16:34 +10:00
parent 6427d625ea
commit 48d39f7c30

View file

@ -1762,8 +1762,11 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category,
errno == ENOENT) ||
statbuf.st_size < FILE_MAXSIZE(channel))
{
(void)fclose(FILE_STREAM(channel));
FILE_STREAM(channel) = NULL;
if (FILE_STREAM(channel) != NULL) {
(void)fclose(
FILE_STREAM(channel));
FILE_STREAM(channel) = NULL;
}
FILE_MAXREACHED(channel) = false;
} else {
/*