From: Yu Watanabe Date: Wed, 28 Jan 2026 04:41:28 +0000 (+0900) Subject: journal: check the length of timestamp field in syslog message X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7e81423fb880abaef9c9db1e2eecb7039ed7a546;p=thirdparty%2Fsystemd.git journal: check the length of timestamp field in syslog message No functional change. Just refactoring and adding assertion. --- diff --git a/src/journal/journald-syslog.c b/src/journal/journald-syslog.c index 7f893738001..8531addf5b9 100644 --- a/src/journal/journald-syslog.c +++ b/src/journal/journald-syslog.c @@ -255,7 +255,7 @@ size_t syslog_parse_identifier(const char **buf, char **identifier, char **pid) return l; } -static int syslog_skip_timestamp(const char **buf) { +static size_t syslog_skip_timestamp(const char **buf) { enum { LETTER, SPACE, @@ -275,8 +275,8 @@ static int syslog_skip_timestamp(const char **buf) { SPACE }; - const char *p, *t; - unsigned i; + const char *p; + size_t i; assert(buf); assert(*buf); @@ -313,13 +313,15 @@ static int syslog_skip_timestamp(const char **buf) { if (*p != ':') return 0; break; - } } - t = *buf; + assert(p >= *buf); + size_t n = p - *buf; + assert(n <= ELEMENTSOF(sequence)); + *buf = p; - return p - t; + return n; } void manager_process_syslog_message(