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-Tag: v257.11~79 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cf34f57335eec2bfb841506f4fb9e9e7ad276134;p=thirdparty%2Fsystemd.git journal: check the length of timestamp field in syslog message No functional change. Just refactoring and adding assertion. (cherry picked from commit 7e81423fb880abaef9c9db1e2eecb7039ed7a546) (cherry picked from commit 842a87e5eb4c71a551d4f62815c8324580f32dbf) (cherry picked from commit 33e61c0af66bd7a5b9014920c86774f09b78ec44) --- diff --git a/src/journal/journald-syslog.c b/src/journal/journald-syslog.c index c04115ab9f1..3d55f9f5cd8 100644 --- a/src/journal/journald-syslog.c +++ b/src/journal/journald-syslog.c @@ -237,7 +237,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, @@ -257,8 +257,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); @@ -295,13 +295,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 server_process_syslog_message(