]> git.ipfire.org Git - thirdparty/systemd.git/commit
catalog: bound item offsets against the mmap in the binary reader main
authorjmestwa-coder <jmestwa@gmail.com>
Sat, 13 Jun 2026 17:58:08 +0000 (23:28 +0530)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 19 Jun 2026 07:54:46 +0000 (16:54 +0900)
commit3a6059e9c04c7146d9c8115abc2d38f98ffd0116
tree4ee83701b574fddcbf4777bba637e6e52a357693
parent7aaa26571da5b3b47c6cd328eafb4e108c7937ae
catalog: bound item offsets against the mmap in the binary reader

The binary catalog reader trusted two values straight from a (possibly
hostile) database: open_mmap() summed header_size + n_items *
catalog_item_size in uint64 with no overflow check, and find_id() added
the matched item's offset to the map base with no upper bound. Reachable
through sd_journal_get_catalog() with $SYSTEMD_CATALOG set, this let
catalog_get()/catalog_list() strdup() a string starting outside the
mapping. Guard the size math with MUL_SAFE/INC_SAFE and reject item
offsets that fall outside the file.
src/libsystemd/sd-journal/catalog.c
src/libsystemd/sd-journal/catalog.h
src/libsystemd/sd-journal/test-catalog.c