]> 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)
committerDavid Tardon <dtardon@redhat.com>
Fri, 12 Oct 2018 12:51:35 +0000 (14:51 +0200)
This can happen if journal_file_close is called from the failure
handling code of journal_file_open before f->fd was established.

src/journal/journal-file.c

index e9dddbc0d79ed8df94d769bfd757ac6104e93411..9c92d6751658399915fee9cd653d1085907513af 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