summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorAlfred Perlstein <alfred@FreeBSD.org>2003-02-10 08:31:28 +0000
committerAlfred Perlstein <alfred@FreeBSD.org>2003-02-10 08:31:28 +0000
commite6cfb1ccd32b55026011103015f7468ef4081bc2 (patch)
tree3048b74b422de09f46320f96ace45cb2d751e90e /lib/libc
parent687e6ad79b42bc784b694dc7bb8a657e722a5cee (diff)
Notes
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/syslog.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/libc/gen/syslog.c b/lib/libc/gen/syslog.c
index 261dd106314e..8c5a2e340a68 100644
--- a/lib/libc/gen/syslog.c
+++ b/lib/libc/gen/syslog.c
@@ -189,13 +189,23 @@ vsyslog(pri, fmt, ap)
return;
}
- /* Substitute error message for %m. */
- for ( ; (ch = *fmt); ++fmt)
+ /*
+ * Substitute error message for %m. Be careful not to
+ * molest an escaped percent "%%m". We want to pass it
+ * on untouched as the format is later parsed by vfprintf.
+ */
+ for ( ; (ch = *fmt); ++fmt) {
if (ch == '%' && fmt[1] == 'm') {
++fmt;
fputs(strerror(saved_errno), fmt_fp);
- } else
+ } else if (ch == '%' && fmt[1] == '%') {
+ ++fmt;
+ fputc(ch, fmt_fp);
fputc(ch, fmt_fp);
+ } else {
+ fputc(ch, fmt_fp);
+ }
+ }
/* Null terminate if room */
fputc(0, fmt_fp);