From 48d39f7c30c8aae867abe563a3f748d715b9b41b Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 19 Jun 2024 17:16:34 +1000 Subject: [PATCH] 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. --- lib/isc/log.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/isc/log.c b/lib/isc/log.c index 472c57d956..53785df3c6 100644 --- a/lib/isc/log.c +++ b/lib/isc/log.c @@ -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 { /*