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

LibCompress: Move XZ header validation into the read function

The constructor is now only concerned with creating the required
streams, which means that it no longer fails for XZ streams with
invalid headers. Instead, everything is parsed and validated during the
first read, preparing us for files with multiple streams.
This commit is contained in:
Tim Schumacher 2023-03-30 12:14:07 +02:00 committed by Andreas Kling
parent 1f166b3a15
commit 00332c9b7d
3 changed files with 19 additions and 14 deletions

View file

@ -118,8 +118,9 @@ TEST_CASE(xz_utils_bad_0_header_magic)
};
auto stream = MUST(try_make<FixedMemoryStream>(compressed));
auto decompressor_or_error = Compress::XzDecompressor::create(move(stream));
EXPECT(decompressor_or_error.is_error());
auto decompressor = MUST(Compress::XzDecompressor::create(move(stream)));
auto buffer_or_error = decompressor->read_until_eof(PAGE_SIZE);
EXPECT(buffer_or_error.is_error());
}
TEST_CASE(xz_utils_bad_0_nonempty_index)
@ -695,8 +696,9 @@ TEST_CASE(xz_utils_bad_1_stream_flags_2)
};
auto stream = MUST(try_make<FixedMemoryStream>(compressed));
auto decompressor_or_error = Compress::XzDecompressor::create(move(stream));
EXPECT(decompressor_or_error.is_error());
auto decompressor = MUST(Compress::XzDecompressor::create(move(stream)));
auto buffer_or_error = decompressor->read_until_eof(PAGE_SIZE);
EXPECT(buffer_or_error.is_error());
}
TEST_CASE(xz_utils_bad_1_stream_flags_3)