anitazha / rpms / systemd

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