]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
log: don't attempt to duplicate closed fd
authorLennart Poettering <lennart@poettering.net>
Fri, 2 Sep 2022 16:35:03 +0000 (18:35 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 2 Sep 2022 18:06:18 +0000 (03:06 +0900)
if the console fd is not open we shouldn#t try to move it out of the 0…2
range.

Fixes: #24535
Alternative-for: #24537

src/basic/log.c

index cac17a76f4d2307162f29854023019332c834835..c5e16d669b0716b99a793dda015e342b46be70b9 100644 (file)
@@ -1460,7 +1460,7 @@ int log_dup_console(void) {
         /* Duplicate the fd we use for fd logging if it's < 3 and use the copy from now on. This call is useful
          * whenever we want to continue logging through the original fd, but want to rearrange stderr. */
 
-        if (console_fd >= 3)
+        if (console_fd < 0 || console_fd >= 3)
                 return 0;
 
         copy = fcntl(console_fd, F_DUPFD_CLOEXEC, 3);