Blob Blame Raw
From 5b21af2bf21f57e9b7ae30217ed01545029256e8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Sun, 5 Mar 2017 10:35:44 -0500
Subject: [PATCH] coredump: fix handling of premature-eof data for --backtrace

We'd fail with an assert in journal_importer_process_data(),
because that function requires the caller to handle EOF themselves.

(cherry picked from commit d74dc4f2d00644c04ad9dc900ef43050fcadaa8b)
---
 src/basic/journal-importer.c | 2 +-
 src/coredump/coredump.c      | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/basic/journal-importer.c b/src/basic/journal-importer.c
index 4c13e46..d25fd35 100644
--- a/src/basic/journal-importer.c
+++ b/src/basic/journal-importer.c
@@ -314,7 +314,7 @@ int journal_importer_process_data(JournalImporter *imp) {
                         return r;
                 if (r == 0) {
                         imp->state = IMPORTER_STATE_EOF;
-                        return r;
+                        return 0;
                 }
                 assert(n > 0);
                 assert(line[n-1] == '\n');
diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c
index 4c4f36a..5828e94 100644
--- a/src/coredump/coredump.c
+++ b/src/coredump/coredump.c
@@ -1326,7 +1326,8 @@ static int process_backtrace(int argc, char *argv[]) {
                         log_error_errno(r, "Failed to parse journal entry on stdin: %m");
                         goto finish;
                 }
-                if (r == 1)
+                if (r == 1 ||                        /* complete entry */
+                    journal_importer_eof(&importer)) /* end of data */
                         break;
         }
 
-- 
2.9.3