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

LibCompress: Avoid overflowing the size of uncompressed LZMA2 chunks

This commit is contained in:
Tim Schumacher 2023-03-29 15:21:03 +02:00 committed by Andreas Kling
parent 023c64011c
commit c020ee8bfa
2 changed files with 53 additions and 1 deletions

View file

@ -54,7 +54,7 @@ ErrorOr<Bytes> Lzma2Decompressor::read_some(Bytes bytes)
// "Uncompressed chunks consist of:
// - A 16-bit big-endian value encoding the data size minus one
// - The data to be copied verbatim into the dictionary and the output"
u16 data_size = TRY(m_stream->read_value<BigEndian<u16>>()) + 1;
u32 data_size = TRY(m_stream->read_value<BigEndian<u16>>()) + 1;
m_in_uncompressed_chunk = true;
m_current_chunk_stream = TRY(try_make<ConstrainedStream>(MaybeOwned { *m_stream }, data_size));