mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-11 17:00:37 +00:00
Meta+Tests: Add a fuzzer and a test for the ILBM decoder
This commit is contained in:
parent
fda5590313
commit
0986533c11
Notes:
sideshowbarker
2024-07-16 20:08:14 +09:00
Author: https://github.com/warpdesign Commit: https://github.com/SerenityOS/serenity/commit/0986533c11 Pull-request: https://github.com/SerenityOS/serenity/pull/20220 Reviewed-by: https://github.com/LucasChollet ✅
5 changed files with 31 additions and 0 deletions
18
Meta/Lagom/Fuzzers/FuzzILBMLoader.cpp
Normal file
18
Meta/Lagom/Fuzzers/FuzzILBMLoader.cpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Copyright (c) 2023, the SerenityOS developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibGfx/ImageFormats/ILBMLoader.h>
|
||||
#include <stdio.h>
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
|
||||
{
|
||||
auto decoder_or_error = Gfx::ILBMImageDecoderPlugin::create({ data, size });
|
||||
if (decoder_or_error.is_error())
|
||||
return 0;
|
||||
auto decoder = decoder_or_error.release_value();
|
||||
(void)decoder->frame(0);
|
||||
return 0;
|
||||
}
|
|
@ -16,6 +16,7 @@ set(FUZZER_TARGETS
|
|||
HttpRequest
|
||||
ICCProfile
|
||||
ICOLoader
|
||||
ILBMLoader
|
||||
IMAPParser
|
||||
JPEGLoader
|
||||
Js
|
||||
|
@ -86,6 +87,7 @@ set(FUZZER_DEPENDENCIES_HebrewDecoder LibTextCodec)
|
|||
set(FUZZER_DEPENDENCIES_HttpRequest LibHTTP)
|
||||
set(FUZZER_DEPENDENCIES_ICCProfile LibGfx)
|
||||
set(FUZZER_DEPENDENCIES_ICOLoader LibGfx)
|
||||
set(FUZZER_DEPENDENCIES_ILBMLoader LibGfx)
|
||||
set(FUZZER_DEPENDENCIES_IMAPParser LibIMAP)
|
||||
set(FUZZER_DEPENDENCIES_JPEGLoader LibGfx)
|
||||
set(FUZZER_DEPENDENCIES_Js LibJS)
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <LibGfx/ImageFormats/BMPLoader.h>
|
||||
#include <LibGfx/ImageFormats/GIFLoader.h>
|
||||
#include <LibGfx/ImageFormats/ICOLoader.h>
|
||||
#include <LibGfx/ImageFormats/ILBMLoader.h>
|
||||
#include <LibGfx/ImageFormats/ImageDecoder.h>
|
||||
#include <LibGfx/ImageFormats/JPEGLoader.h>
|
||||
#include <LibGfx/ImageFormats/JPEGXLLoader.h>
|
||||
|
@ -88,6 +89,15 @@ TEST_CASE(test_bmp_embedded_in_ico)
|
|||
expect_single_frame(*plugin_decoder);
|
||||
}
|
||||
|
||||
TEST_CASE(test_ilbm)
|
||||
{
|
||||
auto file = MUST(Core::MappedFile::map(TEST_INPUT("ilbm/gradient.iff"sv)));
|
||||
EXPECT(Gfx::ILBMImageDecoderPlugin::sniff(file->bytes()));
|
||||
auto plugin_decoder = MUST(Gfx::ILBMImageDecoderPlugin::create(file->bytes()));
|
||||
|
||||
expect_single_frame_of_size(*plugin_decoder, { 320, 200 });
|
||||
}
|
||||
|
||||
TEST_CASE(test_jpeg_sof0_one_scan)
|
||||
{
|
||||
auto file = MUST(Core::MappedFile::map(TEST_INPUT("jpg/rgb24.jpg"sv)));
|
||||
|
|
BIN
Tests/LibGfx/test-inputs/ilbm/gradient.iff
Normal file
BIN
Tests/LibGfx/test-inputs/ilbm/gradient.iff
Normal file
Binary file not shown.
|
@ -30,6 +30,7 @@
|
|||
T(HttpRequest) \
|
||||
T(ICCProfile) \
|
||||
T(ICOLoader) \
|
||||
T(ILBMLoader) \
|
||||
T(IMAPParser) \
|
||||
T(JPEGLoader) \
|
||||
T(Js) \
|
||||
|
|
Loading…
Reference in a new issue