valeriyvdovin / rpms / systemd

Forked from rpms/systemd 4 years ago
Clone

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

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