]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Check that FILE_STREAM(channel) is not already closed
authorMark Andrews <marka@isc.org>
Wed, 19 Jun 2024 07:16:34 +0000 (17:16 +1000)
committerMark Andrews <marka@isc.org>
Wed, 31 Jul 2024 07:36:38 +0000 (17:36 +1000)
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

index 472c57d956a430370deb9fe30175acefd9534d52..53785df3c632bd85deac730720bfdfaff8856ebe 100644 (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 {
                                        /*