summaryrefslogtreecommitdiffstats
path: root/log.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2003-01-07 17:04:18 +1100
committerDamien Miller <djm@mindrot.org>2003-01-07 17:04:18 +1100
commitb93addb6d667b36bdbb298b8b3c581c1738c0c9f (patch)
tree93cd375f6321d9ca2acc5a43cf4fd7eed8832dfa /log.c
parent7df881d20e85ecbd389311cea999162a945774e1 (diff)
- (djm) Bug #111: Run syslog and stderr logging through strnvis to eliminate
nasties. Report from peak@argo.troja.mff.cuni.cz
Diffstat (limited to 'log.c')
-rw-r--r--log.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/log.c b/log.c
index 96626d7d..ead7e902 100644
--- a/log.c
+++ b/log.c
@@ -386,11 +386,14 @@ do_log(LogLevel level, const char *fmt, va_list args)
} else {
vsnprintf(msgbuf, sizeof(msgbuf), fmt, args);
}
+ /* Escape magic chars in output. */
+ strnvis(fmtbuf, msgbuf, sizeof(fmtbuf), VIS_OCTAL);
+
if (log_on_stderr) {
- fprintf(stderr, "%s\r\n", msgbuf);
+ fprintf(stderr, "%s\r\n", fmtbuf);
} else {
openlog(argv0 ? argv0 : __progname, LOG_PID, log_facility);
- syslog(pri, "%.500s", msgbuf);
+ syslog(pri, "%.500s", fmtbuf);
closelog();
}
}