Files
Cole MunzandGitHub 8713d1c47c bit_lib: don't read past the buffer when the bits fit one byte (#4424)
bit_lib_get_bits reads data[position/8 + 1] whenever position isn't
byte-aligned, even when all the requested bits live in the current byte.
When position/8 is the last byte of the buffer that's a one-byte
over-read. The extra byte only contributes bits that get shifted back
out, so the return value is unchanged and optimized builds often drop
the load, but at -O0 AddressSanitizer flags it and the access is still
out of bounds.

Skip the next-byte read when shift + length <= 8. This is the same fix
that already landed in fbtng-corelibs; lib/bit_lib here is an independent
copy that never picked it up, so the TODO FL-3534 comment is still here.

Signed-off-by: Cole Munz <colemunz@gmail.com>
2026-07-27 20:49:10 +03:00
..
2024-07-05 18:27:21 +01:00