From: David Tardon Date: Wed, 10 Oct 2018 11:56:54 +0000 (+0200) Subject: journal-file: avoid calling ftruncate with invalid fd X-Git-Tag: v240~563^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c52368509f48e556be5a4c7a171361b656a25e02;p=thirdparty%2Fsystemd.git journal-file: avoid calling ftruncate with invalid fd This can happen if journal_file_close is called from the failure handling code of journal_file_open before f->fd was established. --- diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c index e9dddbc0d79..9c92d675165 100644 --- a/src/journal/journal-file.c +++ b/src/journal/journal-file.c @@ -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