journal: check the length of timestamp field in syslog message
No functional change. Just refactoring and adding assertion.
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user