daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
ff6046
From fde3fa3e9c0330c7de645ce2140f9dd39640a693 Mon Sep 17 00:00:00 2001
ff6046
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
ff6046
Date: Fri, 7 Dec 2018 10:48:10 +0100
ff6046
Subject: [PATCH] journal-remote: set a limit on the number of fields in a
ff6046
 message
ff6046
ff6046
Existing use of E2BIG is replaced with ENOBUFS (entry too long), and E2BIG is
ff6046
reused for the new error condition (too many fields).
ff6046
ff6046
This matches the change done for systemd-journald, hence forming the second
ff6046
part of the fix for CVE-2018-16865
ff6046
(https://bugzilla.redhat.com/show_bug.cgi?id=1653861).
ff6046
ff6046
(cherry-picked from commit ef4d6abe7c7fab6cbff975b32e76b09feee56074)
ff6046
ff6046
Resolves: #1664977
ff6046
---
ff6046
 src/journal-remote/journal-remote-main.c | 7 +++++--
ff6046
 src/journal-remote/journal-remote.c      | 5 ++++-
ff6046
 2 files changed, 9 insertions(+), 3 deletions(-)
ff6046
ff6046
diff --git a/src/journal-remote/journal-remote-main.c b/src/journal-remote/journal-remote-main.c
ff6046
index e9b3702e8a..5b0bbba310 100644
ff6046
--- a/src/journal-remote/journal-remote-main.c
ff6046
+++ b/src/journal-remote/journal-remote-main.c
ff6046
@@ -211,9 +211,12 @@ static int process_http_upload(
ff6046
                 if (r == -EAGAIN)
ff6046
                         break;
ff6046
                 if (r < 0) {
ff6046
-                        if (r == -E2BIG)
ff6046
-                                log_warning_errno(r, "Entry is too above maximum of %u, aborting connection %p.",
ff6046
+                        if (r == -ENOBUFS)
ff6046
+                                log_warning_errno(r, "Entry is above the maximum of %u, aborting connection %p.",
ff6046
                                                   DATA_SIZE_MAX, connection);
ff6046
+                        else if (r == -E2BIG)
ff6046
+                                log_warning_errno(r, "Entry with more fields than the maximum of %u, aborting connection %p.",
ff6046
+                                                  ENTRY_FIELD_COUNT_MAX, connection);
ff6046
                         else
ff6046
                                 log_warning_errno(r, "Failed to process data, aborting connection %p: %m",
ff6046
                                                   connection);
ff6046
diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c
ff6046
index beb75a1cb4..67e3a70c06 100644
ff6046
--- a/src/journal-remote/journal-remote.c
ff6046
+++ b/src/journal-remote/journal-remote.c
ff6046
@@ -408,7 +408,10 @@ int journal_remote_handle_raw_source(
ff6046
                 log_debug("%zu active sources remaining", s->active);
ff6046
                 return 0;
ff6046
         } else if (r == -E2BIG) {
ff6046
-                log_notice_errno(E2BIG, "Entry too big, skipped");
ff6046
+                log_notice("Entry with too many fields, skipped");
ff6046
+                return 1;
ff6046
+        } else if (r == -ENOBUFS) {
ff6046
+                log_notice("Entry too big, skipped");
ff6046
                 return 1;
ff6046
         } else if (r == -EAGAIN) {
ff6046
                 return 0;