Skip to content

Commit

Permalink
journald: take leading spaces into account in syslog_parse_identifier
Browse files Browse the repository at this point in the history
This is a kind of follow-up to e88baee which should finally fix
the issue which that commit was supposed to fix.
  • Loading branch information
evverx committed Aug 10, 2018
1 parent 30eddcd commit 937b117
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/journal/journald-syslog.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions src/journal/test-journal-syslog.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 937b117

Please sign in to comment.