journald: take leading spaces into account in syslog_parse_identifier

This is a kind of follow-up to e88baee88f which should finally fix
the issue which that commit was supposed to fix.
This commit is contained in:
Evgeny Vereshchagin 2018-08-10 12:55:09 +00:00
parent 30eddcd51b
commit 937b117137
2 changed files with 4 additions and 1 deletions

View File

@ -222,8 +222,9 @@ size_t syslog_parse_identifier(const char **buf, char **identifier, char **pid)
if (p[e] != '\0' && strchr(WHITESPACE, p[e]))
e++;
l = (p - *buf) + e;
*buf = p + e;
return e;
return l;
}
static int syslog_skip_timestamp(const char **buf) {

View File

@ -41,6 +41,8 @@ int main(void) {
test_syslog_parse_identifier(" ", NULL, NULL, " ", 0);
test_syslog_parse_identifier(":", "", NULL, "", 1);
test_syslog_parse_identifier(": ", "", NULL, " ", 2);
test_syslog_parse_identifier(" :", "", NULL, "", 2);
test_syslog_parse_identifier(" pidu:", "pidu", NULL, "", 8);
test_syslog_parse_identifier("pidu:", "pidu", NULL, "", 5);
test_syslog_parse_identifier("pidu: ", "pidu", NULL, "", 6);
test_syslog_parse_identifier("pidu : ", NULL, NULL, "pidu : ", 0);