Tests: Add regression tests for fixed OSS-Fuzz test cases

This commit is contained in:
Tim Ledbetter 2023-10-21 23:22:32 +01:00 committed by Andreas Kling
parent c62dded5cc
commit cb16c217b8
Notes: sideshowbarker 2024-07-17 03:03:44 +09:00
18 changed files with 119 additions and 0 deletions

View File

@ -258,3 +258,16 @@ TEST_CASE(to_lab)
EXPECT_APPROXIMATE_LAB(lab_from_sRGB(0, 255, 255), expected[6]);
EXPECT_APPROXIMATE_LAB(lab_from_sRGB(255, 255, 255), expected[7]);
}
TEST_CASE(malformed_profile)
{
Array test_inputs = {
TEST_INPUT("icc/oss-fuzz-testcase-60281.icc"sv)
};
for (auto test_input : test_inputs) {
auto file = MUST(Core::MappedFile::map(test_input));
auto profile_or_error = Gfx::ICC::Profile::try_load_from_externally_owned_memory(file->bytes());
EXPECT(profile_or_error.is_error());
}
}

View File

@ -69,6 +69,21 @@ TEST_CASE(test_bmp_top_down)
expect_single_frame(*plugin_decoder);
}
TEST_CASE(test_ico_malformed_frame)
{
Array test_inputs = {
TEST_INPUT("ico/oss-fuzz-testcase-62541.ico"sv),
TEST_INPUT("ico/oss-fuzz-testcase-63177.ico"sv)
};
for (auto test_input : test_inputs) {
auto file = MUST(Core::MappedFile::map(test_input));
auto plugin_decoder = TRY_OR_FAIL(Gfx::ICOImageDecoderPlugin::create(file->bytes()));
auto frame_or_error = plugin_decoder->frame(0);
EXPECT(frame_or_error.is_error());
}
}
TEST_CASE(test_gif)
{
auto file = MUST(Core::MappedFile::map(TEST_INPUT("download-animation.gif"sv)));
@ -121,6 +136,33 @@ TEST_CASE(test_ilbm_uncompressed)
EXPECT_EQ(frame.image->get_pixel(8, 0), Gfx::Color(0xee, 0xbb, 0, 255));
}
TEST_CASE(test_ilbm_malformed_header)
{
Array test_inputs = {
TEST_INPUT("ilbm/oss-fuzz-testcase-62033.iff"sv),
};
for (auto test_input : test_inputs) {
auto file = MUST(Core::MappedFile::map(test_input));
auto plugin_decoder_or_error = Gfx::ILBMImageDecoderPlugin::create(file->bytes());
EXPECT(plugin_decoder_or_error.is_error());
}
}
TEST_CASE(test_ilbm_malformed_frame)
{
Array test_inputs = {
TEST_INPUT("ilbm/oss-fuzz-testcase-63296.iff"sv)
};
for (auto test_input : test_inputs) {
auto file = MUST(Core::MappedFile::map(test_input));
auto plugin_decoder = TRY_OR_FAIL(Gfx::ILBMImageDecoderPlugin::create(file->bytes()));
auto frame_or_error = plugin_decoder->frame(0);
EXPECT(frame_or_error.is_error());
}
}
TEST_CASE(test_jpeg_sof0_one_scan)
{
auto file = MUST(Core::MappedFile::map(TEST_INPUT("jpg/rgb24.jpg"sv)));
@ -211,6 +253,33 @@ TEST_CASE(test_jpeg_grayscale_with_app14)
expect_single_frame_of_size(*plugin_decoder, { 80, 80 });
}
TEST_CASE(test_jpeg_malformed_header)
{
Array test_inputs = {
TEST_INPUT("jpg/oss-fuzz-testcase-59785.jpg"sv)
};
for (auto test_input : test_inputs) {
auto file = MUST(Core::MappedFile::map(test_input));
auto plugin_decoder_or_error = Gfx::JPEGImageDecoderPlugin::create(file->bytes());
EXPECT(plugin_decoder_or_error.is_error());
}
}
TEST_CASE(test_jpeg_malformed_frame)
{
Array test_inputs = {
TEST_INPUT("jpg/oss-fuzz-testcase-62584.jpg"sv)
};
for (auto test_input : test_inputs) {
auto file = MUST(Core::MappedFile::map(test_input));
auto plugin_decoder = TRY_OR_FAIL(Gfx::JPEGImageDecoderPlugin::create(file->bytes()));
auto frame_or_error = plugin_decoder->frame(0);
EXPECT(frame_or_error.is_error());
}
}
TEST_CASE(test_pbm)
{
auto file = MUST(Core::MappedFile::map(TEST_INPUT("pnm/buggie-raw.pbm"sv)));
@ -238,6 +307,21 @@ TEST_CASE(test_png)
expect_single_frame(*plugin_decoder);
}
TEST_CASE(test_png_malformed_frame)
{
Array test_inputs = {
TEST_INPUT("png/oss-fuzz-testcase-62371.png"sv),
TEST_INPUT("png/oss-fuzz-testcase-63052.png"sv)
};
for (auto test_input : test_inputs) {
auto file = MUST(Core::MappedFile::map(test_input));
auto plugin_decoder = TRY_OR_FAIL(Gfx::PNGImageDecoderPlugin::create(file->bytes()));
auto frame_or_error = plugin_decoder->frame(0);
EXPECT(frame_or_error.is_error());
}
}
TEST_CASE(test_ppm)
{
auto file = MUST(Core::MappedFile::map(TEST_INPUT("pnm/buggie-raw.ppm"sv)));

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 512 B

View File

@ -12,3 +12,7 @@ install(FILES vp9_4k.webm DESTINATION usr/Tests/LibVideo)
install(FILES vp9_clamp_reference_mvs.webm DESTINATION usr/Tests/LibVideo)
install(FILES vp9_oob_blocks.webm DESTINATION usr/Tests/LibVideo)
install(FILES master_elements_containing_crc32.mkv DESTINATION usr/Tests/LibVideo)
install(FILES oss-fuzz-testcase-52630.vp9 DESTINATION usr/Tests/LibVideo)
install(FILES oss-fuzz-testcase-53977.vp9 DESTINATION usr/Tests/LibVideo)
install(FILES oss-fuzz-testcase-62054.vp9 DESTINATION usr/Tests/LibVideo)
install(FILES oss-fuzz-testcase-63182.vp9 DESTINATION usr/Tests/LibVideo)

View File

@ -59,6 +59,23 @@ TEST_CASE(vp9_oob_blocks)
decode_video("./vp9_oob_blocks.webm"sv, 240);
}
TEST_CASE(vp9_malformed_frame)
{
Array test_inputs = {
"./oss-fuzz-testcase-52630.vp9"sv,
"./oss-fuzz-testcase-53977.vp9"sv,
"./oss-fuzz-testcase-62054.vp9"sv,
"./oss-fuzz-testcase-63182.vp9"sv
};
for (auto test_input : test_inputs) {
auto file = MUST(Core::MappedFile::map(test_input));
Video::VP9::Decoder vp9_decoder;
auto maybe_decoder_error = vp9_decoder.receive_sample(file->bytes());
EXPECT(maybe_decoder_error.is_error());
}
}
BENCHMARK_CASE(vp9_4k)
{
decode_video("./vp9_4k.webm"sv, 2);

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1 @@
I<EFBFBD>

Binary file not shown.