richardphibel / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
b9a53a
From 3521217c88b364e2c5b10a1e35d3c036b1ecba64 Mon Sep 17 00:00:00 2001
b9a53a
From: Evgeny Vereshchagin <evvers@ya.ru>
b9a53a
Date: Fri, 10 Aug 2018 12:55:09 +0000
b9a53a
Subject: [PATCH] journald: take leading spaces into account in
b9a53a
 syslog_parse_identifier
b9a53a
b9a53a
This is a kind of follow-up to e88baee88fad8bc59d3 which should finally fix
b9a53a
the issue which that commit was supposed to fix.
b9a53a
b9a53a
(cherry picked from commit 937b1171378bc1000a34fcdfe9534d898227e35f)
b9a53a
b9a53a
Resolves: #1764560
b9a53a
---
b9a53a
 src/journal/journald-syslog.c     | 3 ++-
b9a53a
 src/journal/test-journal-syslog.c | 2 ++
b9a53a
 2 files changed, 4 insertions(+), 1 deletion(-)
b9a53a
b9a53a
diff --git a/src/journal/journald-syslog.c b/src/journal/journald-syslog.c
b9a53a
index e0b55cc566..ae966763a0 100644
b9a53a
--- a/src/journal/journald-syslog.c
b9a53a
+++ b/src/journal/journald-syslog.c
b9a53a
@@ -223,8 +223,9 @@ size_t syslog_parse_identifier(const char **buf, char **identifier, char **pid)
b9a53a
         if (p[e] != '\0' && strchr(WHITESPACE, p[e]))
b9a53a
                 e++;
b9a53a
 
b9a53a
+        l = (p - *buf) + e;
b9a53a
         *buf = p + e;
b9a53a
-        return e;
b9a53a
+        return l;
b9a53a
 }
b9a53a
 
b9a53a
 static void syslog_skip_date(char **buf) {
b9a53a
diff --git a/src/journal/test-journal-syslog.c b/src/journal/test-journal-syslog.c
b9a53a
index 120477cc9f..415b9d23ca 100644
b9a53a
--- a/src/journal/test-journal-syslog.c
b9a53a
+++ b/src/journal/test-journal-syslog.c
b9a53a
@@ -41,6 +41,8 @@ int main(void) {
b9a53a
         test_syslog_parse_identifier("  ", NULL, NULL, "  ", 0);
b9a53a
         test_syslog_parse_identifier(":", "", NULL, "", 1);
b9a53a
         test_syslog_parse_identifier(":  ", "", NULL, " ", 2);
b9a53a
+        test_syslog_parse_identifier(" :", "", NULL, "", 2);
b9a53a
+        test_syslog_parse_identifier("   pidu:", "pidu", NULL, "", 8);
b9a53a
         test_syslog_parse_identifier("pidu:", "pidu", NULL, "", 5);
b9a53a
         test_syslog_parse_identifier("pidu: ", "pidu", NULL, "", 6);
b9a53a
         test_syslog_parse_identifier("pidu : ", NULL, NULL, "pidu : ", 0);