Skip to content

Commit 5b3cc0c

Browse files
nojimapoettering
authored andcommitted
journald: fix assertion failure on journal_file_link_data. (systemd#5843)
When some error occurs during the initialization of JournalFile, the JournalFile can be left without hash tables created. When later trying to append an entry to that file, the assertion in journal_file_link_data() fails, and journald crashes. This patch fix this issue by checking *_hash_table_size in journal_file_verify_header().
1 parent db7076b commit 5b3cc0c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/journal/journal-file.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,9 @@ static int journal_file_verify_header(JournalFile *f) {
613613
return -EBUSY;
614614
}
615615

616+
if (f->header->field_hash_table_size == 0 || f->header->data_hash_table_size == 0)
617+
return -EBADMSG;
618+
616619
/* Don't permit appending to files from the future. Because otherwise the realtime timestamps wouldn't
617620
* be strictly ordered in the entries in the file anymore, and we can't have that since it breaks
618621
* bisection. */

0 commit comments

Comments
 (0)