diff options
author | Ben Wiederhake <BenWiederhake.GitHub@gmx.de> | 2022-09-16 19:21:29 +0200 |
---|---|---|
committer | Brian Gianforcaro <b.gianfo@gmail.com> | 2022-09-17 04:10:11 +0000 |
commit | 8de7a91571a30682aea95338b8184c33802a62dd (patch) | |
tree | 08dbdfdea48ad50443adb1c1e5f0df02a6022717 /Userland | |
parent | fe48fed4fab7151a007e01fb679ecd0ac1f02164 (diff) | |
download | serenity-8de7a91571a30682aea95338b8184c33802a62dd.zip |
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.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibCompress/Brotli.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Userland/Libraries/LibCompress/Brotli.cpp b/Userland/Libraries/LibCompress/Brotli.cpp index faae273bbe..2f150fea81 100644 --- a/Userland/Libraries/LibCompress/Brotli.cpp +++ b/Userland/Libraries/LibCompress/Brotli.cpp @@ -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) |