mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2026-08-20 23:39:48 +00:00
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>