- (djm) [log.c] bz #111: Escape more control characters when sending data

to syslog; from peak AT argo.troja.mff.cuni.cz
This commit is contained in:
Damien Miller 2004-07-21 10:52:13 +10:00
parent 816bd0d087
commit 23a7027e48
2 changed files with 10 additions and 2 deletions

View File

@ -1,3 +1,7 @@
20040719
- (djm) [log.c] bz #111: Escape more control characters when sending data
to syslog; from peak AT argo.troja.mff.cuni.cz
20040719 20040719
- (djm) [openbsd-compat/bsd-arc4random.c] Discard early keystream, like OpenBSD - (djm) [openbsd-compat/bsd-arc4random.c] Discard early keystream, like OpenBSD
ok dtucker@ ok dtucker@
@ -1535,4 +1539,4 @@
- (djm) Trim deprecated options from INSTALL. Mention UsePAM - (djm) Trim deprecated options from INSTALL. Mention UsePAM
- (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
$Id: ChangeLog,v 1.3480 2004/07/19 17:19:26 tim Exp $ $Id: ChangeLog,v 1.3481 2004/07/21 00:52:13 djm Exp $

6
log.c
View File

@ -51,6 +51,9 @@ static char *argv0;
extern char *__progname; extern char *__progname;
#define LOG_SYSLOG_VIS (VIS_CSTYLE|VIS_NL|VIS_TAB|VIS_OCTAL)
#define LOG_STDERR_VIS (VIS_SAFE|VIS_OCTAL)
/* textual representation of log-facilities/levels */ /* textual representation of log-facilities/levels */
static struct { static struct {
@ -316,7 +319,8 @@ do_log(LogLevel level, const char *fmt, va_list args)
} else { } else {
vsnprintf(msgbuf, sizeof(msgbuf), fmt, args); vsnprintf(msgbuf, sizeof(msgbuf), fmt, args);
} }
strnvis(fmtbuf, msgbuf, sizeof(fmtbuf), VIS_SAFE|VIS_OCTAL); strnvis(fmtbuf, msgbuf, sizeof(fmtbuf),
log_on_stderr ? LOG_STDERR_VIS : LOG_SYSLOG_VIS);
if (log_on_stderr) { if (log_on_stderr) {
snprintf(msgbuf, sizeof msgbuf, "%s\r\n", fmtbuf); snprintf(msgbuf, sizeof msgbuf, "%s\r\n", fmtbuf);
write(STDERR_FILENO, msgbuf, strlen(msgbuf)); write(STDERR_FILENO, msgbuf, strlen(msgbuf));