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.
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.