|
Message-Id: <1404909258-83701-1-git-send-email-clement.vasseur@gmail.com> Date: Wed, 9 Jul 2014 14:34:18 +0200 From: Clément Vasseur <clement.vasseur@...il.com> To: musl@...ts.openwall.com Subject: [PATCH] fix the %m specifier in syslog errno must be saved upon vsyslog entry, otherwise its value could be changed by some libc function before reaching the %m handler in vsnprintf. --- src/misc/syslog.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/misc/syslog.c b/src/misc/syslog.c index 1cd61ce..57f1d75 100644 --- a/src/misc/syslog.c +++ b/src/misc/syslog.c @@ -7,6 +7,7 @@ #include <signal.h> #include <string.h> #include <pthread.h> +#include <errno.h> #include "libc.h" #include "atomic.h" @@ -76,6 +77,7 @@ static void _vsyslog(int priority, const char *message, va_list ap) time_t now; struct tm tm; char buf[256]; + int errno_save = errno; int pid; int l, l2; @@ -93,6 +95,7 @@ static void _vsyslog(int priority, const char *message, va_list ap) pid = (log_opt & LOG_PID) ? getpid() : 0; l = snprintf(buf, sizeof buf, "<%d>%s %s%s%.0d%s: ", priority, timebuf, log_ident, "["+!pid, pid, "]"+!pid); + errno = errno_save; l2 = vsnprintf(buf+l, sizeof buf - l, message, ap); if (l2 >= 0) { if (l2 >= sizeof buf - l) l = sizeof buf - 1; -- 2.0.1
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.