libnxz / power-gzip

POWER NX zlib compliant library
23 stars 18 forks source link

Fix spanning flush when tebc = 0 or tebc > 5 #147

Closed mscastanho closed 2 years ago

mscastanho commented 2 years ago

The size of a literal block header ranges between 35 and 42 bits, depending on the amount of padding bits needed to align the start of the literal data to a byte boundary. For this reason, append_btype00_header may write 4 or 5 bytes, and this amount is returned to the caller.

However, rewrite_spanning_flush was not taking that value into consideration, and was always copying only 4 bytes from the tmp buffer to the output, creating invalid block headers.