Blame SOURCES/0033-journal-file-avoid-calling-ftruncate-with-invalid-fd.patch

a3e2b5
From ebdb96247433d920b391672e019da9402aabd351 Mon Sep 17 00:00:00 2001
a3e2b5
From: David Tardon <dtardon@redhat.com>
a3e2b5
Date: Wed, 10 Oct 2018 13:56:54 +0200
a3e2b5
Subject: [PATCH] journal-file: avoid calling ftruncate with invalid fd
a3e2b5
a3e2b5
This can happen if journal_file_close is called from the failure
a3e2b5
handling code of journal_file_open before f->fd was established.
a3e2b5
a3e2b5
(cherry picked from commit c52368509f48e556be5a4c7a171361b656a25e02)
a3e2b5
a3e2b5
Resolves: #1602706
a3e2b5
---
a3e2b5
 src/journal/journal-file.c | 3 +++
a3e2b5
 1 file changed, 3 insertions(+)
a3e2b5
a3e2b5
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
a3e2b5
index 62e7f68a13..efc3ee052b 100644
a3e2b5
--- a/src/journal/journal-file.c
a3e2b5
+++ b/src/journal/journal-file.c
a3e2b5
@@ -1846,6 +1846,9 @@ static int journal_file_append_entry_internal(
a3e2b5
 void journal_file_post_change(JournalFile *f) {
a3e2b5
         assert(f);
a3e2b5
 
a3e2b5
+        if (f->fd < 0)
a3e2b5
+                return;
a3e2b5
+
a3e2b5
         /* inotify() does not receive IN_MODIFY events from file
a3e2b5
          * accesses done via mmap(). After each access we hence
a3e2b5
          * trigger IN_MODIFY by truncating the journal file to its