1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 14:27:35 +00:00

LibCompress: Avoid buffer overrun when building canonical Huffman code

Previously, decompressing a DEFLATE stream an invalid canonical
Huffman code could cause a buffer overrun. We now return an error in
this case.
This commit is contained in:
Tim Ledbetter 2023-10-09 17:54:49 +01:00 committed by Tim Schumacher
parent bc6638682d
commit 2f26a7bb12
2 changed files with 10 additions and 0 deletions

View file

@ -55,6 +55,13 @@ TEST_CASE(canonical_code_complex)
EXPECT_EQ(MUST(huffman.read_symbol(bit_stream)), output[idx]);
}
TEST_CASE(invalid_canonical_code)
{
Array<u8, 257> code;
code.fill(0x08);
EXPECT(Compress::CanonicalCode::from_bytes(code).is_error());
}
TEST_CASE(deflate_decompress_compressed_block)
{
Array<u8, 28> const compressed {