diff options
author | Damien Miller <djm@mindrot.org> | 2004-07-21 10:52:13 +1000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2004-07-21 10:52:13 +1000 |
commit | 23a7027e48c1b8d7f54c04319a6e0433d1c19e23 (patch) | |
tree | 96b8258ef2c991390fe8d3cf4e7b239313d3d622 /log.c | |
parent | 816bd0d0870c8c4dae5243734fab80568bce15f5 (diff) |
- (djm) [log.c] bz #111: Escape more control characters when sending data
to syslog; from peak AT argo.troja.mff.cuni.cz
Diffstat (limited to 'log.c')
-rw-r--r-- | log.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -51,6 +51,9 @@ static char *argv0; | |||
51 | 51 | ||
52 | extern char *__progname; | 52 | extern char *__progname; |
53 | 53 | ||
54 | #define LOG_SYSLOG_VIS (VIS_CSTYLE|VIS_NL|VIS_TAB|VIS_OCTAL) | ||
55 | #define LOG_STDERR_VIS (VIS_SAFE|VIS_OCTAL) | ||
56 | |||
54 | /* textual representation of log-facilities/levels */ | 57 | /* textual representation of log-facilities/levels */ |
55 | 58 | ||
56 | static struct { | 59 | static struct { |
@@ -316,7 +319,8 @@ do_log(LogLevel level, const char *fmt, va_list args) | |||
316 | } else { | 319 | } else { |
317 | vsnprintf(msgbuf, sizeof(msgbuf), fmt, args); | 320 | vsnprintf(msgbuf, sizeof(msgbuf), fmt, args); |
318 | } | 321 | } |
319 | strnvis(fmtbuf, msgbuf, sizeof(fmtbuf), VIS_SAFE|VIS_OCTAL); | 322 | strnvis(fmtbuf, msgbuf, sizeof(fmtbuf), |
323 | log_on_stderr ? LOG_STDERR_VIS : LOG_SYSLOG_VIS); | ||
320 | if (log_on_stderr) { | 324 | if (log_on_stderr) { |
321 | snprintf(msgbuf, sizeof msgbuf, "%s\r\n", fmtbuf); | 325 | snprintf(msgbuf, sizeof msgbuf, "%s\r\n", fmtbuf); |
322 | write(STDERR_FILENO, msgbuf, strlen(msgbuf)); | 326 | write(STDERR_FILENO, msgbuf, strlen(msgbuf)); |