mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH] fix the %m specifier in syslog
@ 2014-07-09 12:34 Clément Vasseur
  2014-07-12  0:04 ` Rich Felker
  0 siblings, 1 reply; 4+ messages in thread
From: Clément Vasseur @ 2014-07-09 12:34 UTC (permalink / raw)
  To: musl

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



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] fix the %m specifier in syslog
  2014-07-09 12:34 [PATCH] fix the %m specifier in syslog Clément Vasseur
@ 2014-07-12  0:04 ` Rich Felker
  2014-07-12  6:52   ` Szabolcs Nagy
  0 siblings, 1 reply; 4+ messages in thread
From: Rich Felker @ 2014-07-12  0:04 UTC (permalink / raw)
  To: musl

On Wed, Jul 09, 2014 at 02:34:18PM +0200, Clément Vasseur wrote:
> errno must be saved upon vsyslog entry, otherwise its value could be
> changed by some libc function before reaching the %m handler in
> vsnprintf.

Committed.

Rich


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] fix the %m specifier in syslog
  2014-07-12  0:04 ` Rich Felker
@ 2014-07-12  6:52   ` Szabolcs Nagy
  2014-07-12 13:55     ` Rich Felker
  0 siblings, 1 reply; 4+ messages in thread
From: Szabolcs Nagy @ 2014-07-12  6:52 UTC (permalink / raw)
  To: musl

* Rich Felker <dalias@libc.org> [2014-07-11 20:04:13 -0400]:
> On Wed, Jul 09, 2014 at 02:34:18PM +0200, Clément Vasseur wrote:
> > errno must be saved upon vsyslog entry, otherwise its value could be
> > changed by some libc function before reaching the %m handler in
> > vsnprintf.
> 
> Committed.

i think the COPYRIGHT file should be updated with new contributors
(it will be harder to track them down later)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] fix the %m specifier in syslog
  2014-07-12  6:52   ` Szabolcs Nagy
@ 2014-07-12 13:55     ` Rich Felker
  0 siblings, 0 replies; 4+ messages in thread
From: Rich Felker @ 2014-07-12 13:55 UTC (permalink / raw)
  To: musl

On Sat, Jul 12, 2014 at 08:52:47AM +0200, Szabolcs Nagy wrote:
> * Rich Felker <dalias@libc.org> [2014-07-11 20:04:13 -0400]:
> > On Wed, Jul 09, 2014 at 02:34:18PM +0200, Clément Vasseur wrote:
> > > errno must be saved upon vsyslog entry, otherwise its value could be
> > > changed by some libc function before reaching the %m handler in
> > > vsnprintf.
> > 
> > Committed.
> 
> i think the COPYRIGHT file should be updated with new contributors
> (it will be harder to track them down later)

Yes, but it's actually not as bad as it looks. We can just check the
git log for the last commit to COPYRIGHT then review commits between
then and now. But I agree we should do it more often. Thanks for the
reminder!

Rich


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-07-12 13:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-09 12:34 [PATCH] fix the %m specifier in syslog Clément Vasseur
2014-07-12  0:04 ` Rich Felker
2014-07-12  6:52   ` Szabolcs Nagy
2014-07-12 13:55     ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).