From 7f3ab33f20f19ad5b8fdd40bd77d35a0da355347 Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Sat, 10 Apr 2021 23:29:40 -0300 Subject: misc: syslog: Use CLOC_EXEC with _PATH_CONSOLE (BZ #17145) The syslog open the '/dev/console' for LOG_CONS without O_CLOEXEC, which might leak in multithread programs that call fork. Checked on x86_64-linux-gnu. --- misc/syslog.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'misc') diff --git a/misc/syslog.c b/misc/syslog.c index 18330a3..e228860 100644 --- a/misc/syslog.c +++ b/misc/syslog.c @@ -284,7 +284,8 @@ __vsyslog_internal(int pri, const char *fmt, va_list ap, * syslogd failure. */ if (LogStat & LOG_CONS && - (fd = __open(_PATH_CONSOLE, O_WRONLY|O_NOCTTY, 0)) >= 0) + (fd = __open(_PATH_CONSOLE, O_WRONLY|O_NOCTTY|O_CLOEXEC, + 0)) >= 0) { __dprintf (fd, "%s\r\n", buf + msgoff); (void)__close(fd); -- cgit v1.1