]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal-file: avoid calling ftruncate with invalid fd
authorDavid Tardon <dtardon@redhat.com>
Wed, 10 Oct 2018 11:56:54 +0000 (13:56 +0200)
committerLukas Nykryn <lnykryn@redhat.com>
Mon, 29 Oct 2018 09:46:41 +0000 (10:46 +0100)
This can happen if journal_file_close is called from the failure
handling code of journal_file_open before f->fd was established.

(cherry picked from commit c52368509f48e556be5a4c7a171361b656a25e02)

Resolves: #1602706

src/journal/journal-file.c

index 62e7f68a13762891f963774f9b39b723c2e8af00..efc3ee052b260ae3b3c506488016fa4a02145858 100644 (file)
@@ -1846,6 +1846,9 @@ static int journal_file_append_entry_internal(
 void journal_file_post_change(JournalFile *f) {
         assert(f);
 
+        if (f->fd < 0)
+                return;
+
         /* inotify() does not receive IN_MODIFY events from file
          * accesses done via mmap(). After each access we hence
          * trigger IN_MODIFY by truncating the journal file to its