journal: check the length of timestamp field in syslog message

No functional change. Just refactoring and adding assertion.
This commit is contained in:
Yu Watanabe
2026-02-03 21:43:17 +09:00
parent 8d607f93b7
commit 7e81423fb8
+8 -6
View File
@@ -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(