The loop at 2179 in isal_inflate_stateless() exits when decode_literal_block() returns 1 (end of input), which causes the CRC check to be skipped and the function to return 1 despite the decoding going well.
I think that loop runs one too many times. My compressed buffer is 515 bytes, and the uncompressed data is 1024 bytes.
The initial call to decode_huffman_code_block_stateless() consumes the entire input and emits the entire output and returns 0.
avail_in = 0 and total_out = 1024 after decode_huffman_code_block_stateless() returns, but block_state is not set to ISAL_BLOCK_INPUT_DONE (it's left to ISAL_BLOCK_NEW_HDR) therefore the loop loops and calls read_hdr() which succeeds and ends up calling decode_literal_block() as block_state is now ISAL_BLOCK_TYPE0.
The loop must exit after decode_huffman_code_block_stateless() has consumed all the input bytes. Perhaps that function should set the block state to ISAL_BLOCK_INPUT_DONE?
As a quickfix, I changed lines 2192-93 from
to
if (ret || !state->avail_in)
break;
where the reasoning is "if stateless (implicit in this function) and no more input" -> done.
The loop at 2179 in isal_inflate_stateless() exits when decode_literal_block() returns 1 (end of input), which causes the CRC check to be skipped and the function to return 1 despite the decoding going well.
I think that loop runs one too many times. My compressed buffer is 515 bytes, and the uncompressed data is 1024 bytes.
The initial call to decode_huffman_code_block_stateless() consumes the entire input and emits the entire output and returns 0.
avail_in = 0 and total_out = 1024 after decode_huffman_code_block_stateless() returns, but block_state is not set to ISAL_BLOCK_INPUT_DONE (it's left to ISAL_BLOCK_NEW_HDR) therefore the loop loops and calls read_hdr() which succeeds and ends up calling decode_literal_block() as block_state is now ISAL_BLOCK_TYPE0.
The loop must exit after decode_huffman_code_block_stateless() has consumed all the input bytes. Perhaps that function should set the block state to ISAL_BLOCK_INPUT_DONE?
As a quickfix, I changed lines 2192-93 from
to
where the reasoning is "if stateless (implicit in this function) and no more input" -> done.