mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-08 12:56:23 +03:00
LibCompress+Tests: Demonstrate and fix faulty metadata length
The test-case is heavily inspired by: https://github.com/google/brotli/blob/master/tests/testdata/x.compressed.01 Or in words: A metadata meta-block containing `Y` (which should be ignored), and then the actual data (a single `Z`). The bug used to skip one metadata byte too few, and thus read garbage.
This commit is contained in:
parent
fe48fed4fa
commit
8de7a91571
Notes:
sideshowbarker
2024-07-17 07:02:37 +09:00
Author: https://github.com/BenWiederhake Commit: https://github.com/SerenityOS/serenity/commit/8de7a91571 Pull-request: https://github.com/SerenityOS/serenity/pull/15265
@ -75,6 +75,11 @@ TEST_CASE(brotli_decompress_katica_regular_10_font)
|
||||
run_test("KaticaRegular10.font"sv);
|
||||
}
|
||||
|
||||
TEST_CASE(brotli_single_z)
|
||||
{
|
||||
run_test("single-z.txt"sv);
|
||||
}
|
||||
|
||||
TEST_CASE(brotli_decompress_zero_one_bin)
|
||||
{
|
||||
// This makes sure that the tests will run both on target and in Lagom.
|
||||
|
1
Tests/LibCompress/brotli-test-files/single-z.txt
Normal file
1
Tests/LibCompress/brotli-test-files/single-z.txt
Normal file
@ -0,0 +1 @@
|
||||
Z
|
BIN
Tests/LibCompress/brotli-test-files/single-z.txt.br
Normal file
BIN
Tests/LibCompress/brotli-test-files/single-z.txt.br
Normal file
Binary file not shown.
@ -605,7 +605,7 @@ ErrorOr<Bytes> BrotliDecompressionStream::read(Bytes output_buffer)
|
||||
return Error::from_string_literal("invalid reserved bit");
|
||||
|
||||
size_t skip_bytes = TRY(m_input_stream.read_bits(2));
|
||||
size_t skip_length = TRY(m_input_stream.read_bits(8 * skip_bytes));
|
||||
size_t skip_length = 1 + TRY(m_input_stream.read_bits(8 * skip_bytes));
|
||||
|
||||
u8 remainder = m_input_stream.align_to_byte_boundary();
|
||||
if (remainder != 0)
|
||||
|
Loading…
Reference in New Issue
Block a user