]> git.ipfire.org Git - thirdparty/systemd.git/commit
journal: Fix upwards iteration of entry items in case of corruption
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 7 Feb 2022 20:15:07 +0000 (20:15 +0000)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 7 Feb 2022 20:40:28 +0000 (20:40 +0000)
commitaa00163d79309f9873512a4cc14a48c05fee7c65
treed14b07db3a25f088fda807799d6cdf6d4c099c79
parent2f7a0648cdf73d30bae6d0ab627abe77c4ba90ec
journal: Fix upwards iteration of entry items in case of corruption

8d801e35cb155faa08235a5af8b4d6ad60715837 didn't take into account
upwards iteration of entry items when we're working on a corrupted
journal file. Instead of moving to the previous entry array, we'd
always move to the next array, regardless of the iteration direction.

To fix this, we introduce bump_entry_array() that moves to the next
or previous entry array depending on the given direction. Since the
entry array chains are singly linked lists, we have to start iterating
from the front to find the previous array. We only reach this logic
if we're working on a corrupted journal file so being slow here shouldn't
matter too much.
src/libsystemd/sd-journal/journal-file.c