diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2015-01-27 08:00:11 -0500 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2015-02-01 17:21:39 -0500 |
commit | 5ffa8c818120e35c89becd938d160235c069dd12 (patch) | |
tree | e4a1ce20a003e23618bd54f49cb4acf68aed70cd /src/journal/journald-stream.c | |
parent | 294929f8916ca37d89ccb1757868d22f8068c56b (diff) |
Add a snprinf wrapper which checks that the buffer was big enough
If we scale our buffer to be wide enough for the format string, we
should expect that the calculation was correct.
char_array_0() invocations are removed, since snprintf nul-terminates
the output in any case.
A similar wrapper is used for strftime calls, but only in timedatectl.c.
Diffstat (limited to 'src/journal/journald-stream.c')
-rw-r--r-- | src/journal/journald-stream.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/journal/journald-stream.c b/src/journal/journald-stream.c index eabe019bfc..942a857803 100644 --- a/src/journal/journald-stream.c +++ b/src/journal/journald-stream.c @@ -223,7 +223,7 @@ static int stdout_stream_log(StdoutStream *s, const char *p) { struct iovec iovec[N_IOVEC_META_FIELDS + 5]; int priority; char syslog_priority[] = "PRIORITY=\0"; - char syslog_facility[sizeof("SYSLOG_FACILITY=") + DECIMAL_STR_MAX(priority)]; + char syslog_facility[sizeof("SYSLOG_FACILITY=")-1 + DECIMAL_STR_MAX(int) + 1]; _cleanup_free_ char *message = NULL, *syslog_identifier = NULL; unsigned n = 0; char *label = NULL; @@ -258,7 +258,7 @@ static int stdout_stream_log(StdoutStream *s, const char *p) { IOVEC_SET_STRING(iovec[n++], syslog_priority); if (priority & LOG_FACMASK) { - snprintf(syslog_facility, sizeof(syslog_facility), "SYSLOG_FACILITY=%i", LOG_FAC(priority)); + xsprintf(syslog_facility, "SYSLOG_FACILITY=%i", LOG_FAC(priority)); IOVEC_SET_STRING(iovec[n++], syslog_facility); } |