]> git.ipfire.org Git - thirdparty/haproxy.git/commit
IMPORT: slz/uslz: fix incorrect sign extension in shift when reading the adler32...
authorAurelien DARRAGON <adarragon@haproxy.com>
Tue, 11 Aug 2026 16:16:52 +0000 (18:16 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Wed, 12 Aug 2026 07:14:07 +0000 (09:14 +0200)
commit08979193e50d69915848d4b24c8cfcfd7e90d535
tree8c5c01d7bba49ca2f08afb596c784787bba6f8e1
parent086cc5e5506897c34a6a6f498d0519e49a8f1e75
IMPORT: slz/uslz: fix incorrect sign extension in shift when reading the adler32 trailer

The zlib trailer is assembled byte by byte into the 64-bit bit accumulator:

    bit_accum |= in_ptr[0] << (24 - num_bits);

in_ptr[0] is an unsigned char, that is unfortunately promoted to signed
int when shifted left, thus introducing a sign bit in upper bits if bit 7
was set with num_bits=0, that gets sign-extended to 64-bit in the
accumulator, resulting in a wrong checksum (and the stream is rejected
with USLZ_DECODE_E_BAD_CRC). Let's just cast it to uint32_t before shifting
to fix this. Note that other similar places already had the cast, this one
was just overlooked.

This is libslz upstream commit 98cf96c18d5b4636886ac66b9b6dbec323eaf11c
src/uslz.c