teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/0265-journald-take-leading-spaces-into-account-in-syslog_.patch

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