anitazha / rpms / systemd

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