mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:27:45 +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:
parent
bc6638682d
commit
2f26a7bb12
2 changed files with 10 additions and 0 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue