From 5ffa8c818120e35c89becd938d160235c069dd12 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Tue, 27 Jan 2015 08:00:11 -0500 Subject: 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. --- src/journal/sd-journal.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/journal/sd-journal.c') diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index 9bc426faf8..9dea5470be 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -1178,8 +1178,7 @@ static bool file_type_wanted(int flags, const char *filename) { if (flags & SD_JOURNAL_CURRENT_USER) { char prefix[5 + DECIMAL_STR_MAX(uid_t) + 1]; - assert_se(snprintf(prefix, sizeof(prefix), "user-"UID_FMT, getuid()) - < (int) sizeof(prefix)); + xsprintf(prefix, "user-"UID_FMT, getuid()); if (file_has_type_prefix(prefix, filename)) return true; -- cgit v1.2.3-54-g00ecf