Skip to content

Commit

Permalink
Fuzzers: Add JPEG2000 fuzzer
Browse files Browse the repository at this point in the history
  • Loading branch information
nico committed Mar 23, 2024
1 parent efdccde commit 970082f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Meta/Lagom/Fuzzers/FuzzJPEG2000Loader.cpp
@@ -0,0 +1,20 @@
/*
* Copyright (c) 2024, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/

#include <LibGfx/ImageFormats/JPEG2000Loader.h>
#include <stddef.h>
#include <stdint.h>

extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
{
AK::set_debug_enabled(false);
auto decoder_or_error = Gfx::JPEG2000ImageDecoderPlugin::create({ data, size });
if (decoder_or_error.is_error())
return 0;
auto decoder = decoder_or_error.release_value();
(void)decoder->frame(0);
return 0;
}
2 changes: 2 additions & 0 deletions Meta/Lagom/Fuzzers/fuzzers.cmake
Expand Up @@ -20,6 +20,7 @@ set(FUZZER_TARGETS
ILBMLoader
IMAPParser
JBIG2Loader
JPEG2000Loader
JPEGLoader
Js
JsonParser
Expand Down Expand Up @@ -94,6 +95,7 @@ set(FUZZER_DEPENDENCIES_ICOLoader LibGfx)
set(FUZZER_DEPENDENCIES_ILBMLoader LibGfx)
set(FUZZER_DEPENDENCIES_IMAPParser LibIMAP)
set(FUZZER_DEPENDENCIES_JBIG2Loader LibGfx)
set(FUZZER_DEPENDENCIES_JPEG2000Loader LibGfx)
set(FUZZER_DEPENDENCIES_JPEGLoader LibGfx)
set(FUZZER_DEPENDENCIES_Js LibJS)
set(FUZZER_DEPENDENCIES_LzmaDecompression LibArchive LibCompress)
Expand Down
1 change: 1 addition & 0 deletions Userland/Utilities/test-fuzz.cpp
Expand Up @@ -34,6 +34,7 @@
T(ILBMLoader) \
T(IMAPParser) \
T(JBIG2Loader) \
T(JPEG2000Loader) \
T(JPEGLoader) \
T(Js) \
T(JsonParser) \
Expand Down

0 comments on commit 970082f

Please sign in to comment.