]> git.ipfire.org Git - thirdparty/systemd.git/commit
uid-range: fix out-of-bounds write in uid_range_partition() 42732/head
authorLuca Boccassi <luca.boccassi@gmail.com>
Wed, 24 Jun 2026 12:56:37 +0000 (13:56 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Thu, 25 Jun 2026 09:28:54 +0000 (10:28 +0100)
commitd30e87ea49b2dc1dc6277ca447b0aaac03f49cde
treeea32ff9b422db2f9995eabfb92394c62634b9721
parentf66144cf2acf51dda7e0a44f7590fc102e596c13
uid-range: fix out-of-bounds write in uid_range_partition()

uid_range_partition() filled the grown entries[] buffer backwards in
place. The backward-fill invariant (the write cursor stays above the
read index) only holds when every source entry contributes at least
one partition; an entry with nr < size contributes zero, so the cursor
stalls while the read index keeps descending. A later multi-part
entry's writes then overwrite the still-live zero-part slot, the
corrupted slot is re-read as a one-part entry, and the next
range->entries[--t] underflows.

Add a forward compaction first pass that drops the zero-part entries
before the backward fill.

Follow-up for 025439faaa8c053fab9fd01fb5f45fb819408bc5

Co-Authored-by: Paul Meyer <katexochen0@gmail.com>
src/basic/uid-range.c
src/test/test-uid-range.c