]> git.99rst.org Git - git.git/commit
reftable/basics: fix OOB read on binary search of empty range
authorPatrick Steinhardt <redacted>
Fri, 3 Jul 2026 12:58:46 +0000 (14:58 +0200)
committerJunio C Hamano <redacted>
Fri, 3 Jul 2026 18:08:02 +0000 (11:08 -0700)
commit657654b1aa0c4a101a55c46ab14c96bdf95dc3b7
treef5a2e9654892a0db361740831497dd48d3fc0cf6
parentadf45165e65beb4bc5c291b8debfcc3ed967aeb8
reftable/basics: fix OOB read on binary search of empty range

`binsearch()` performs a binary search over a range of `sz` elements by
repeatedly calling the comparison function with indices into that range.
When the range is empty though, there is no valid index to call the
comparison function with. We still end up executing the comparison
function though with an index of 0, which of course will cause an
out-of-bounds read.

Return early when the range is empty.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
reftable/basics.c
t/unit-tests/u-reftable-basics.c
git clone https://git.99rst.org/PROJECT