]> git.ipfire.org Git - thirdparty/git.git/commit
reftable/block: fix error handling when searching restart points
authorPatrick Steinhardt <ps@pks.im>
Wed, 3 Apr 2024 06:04:18 +0000 (08:04 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 3 Apr 2024 16:16:50 +0000 (09:16 -0700)
commitf9e88544f5488adf07fd9c217ab6ab8f433a1ce8
tree5993eb2293368b253893d4e3764c45ddc3a95835
parent77307a61d6d6f17dcbf7534c512af370185a4391
reftable/block: fix error handling when searching restart points

When doing the binary search over restart points in a block we need to
decode the record keys. This decoding step can result in an error when
the block is corrupted, which we indicate to the caller of the binary
search by setting `args.error = 1`. But the only caller that exists
mishandles this because it in fact performs the error check before
calling `binsearch()`.

Fix this bug by checking for errors at the right point in time.
Furthermore, refactor `binsearch()` so that it aborts the search in case
the callback function returns a negative value so that we don't
needlessly continue to search the block.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
reftable/basics.c
reftable/basics.h
reftable/block.c