]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journald: take leading spaces into account in syslog_parse_identifier 9863/head
authorEvgeny Vereshchagin <evvers@ya.ru>
Fri, 10 Aug 2018 12:55:09 +0000 (12:55 +0000)
committerEvgeny Vereshchagin <evvers@ya.ru>
Fri, 10 Aug 2018 13:35:06 +0000 (13:35 +0000)
This is a kind of follow-up to e88baee88fad8bc59d3 which should finally fix
the issue which that commit was supposed to fix.

src/journal/journald-syslog.c
src/journal/test-journal-syslog.c

index 6dc6b0741afbae7586155acfa88292deffd752b4..72b73c2c0fb49457c22705a93739c5cf25b6b3b9 100644 (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) {
index 120477cc9f83f6fc44bdf010ef8a193294bae805..415b9d23ca897ebe1f2d45e72e8fb3bc01028527 100644 (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);