Skip to content

Commit

Permalink
Lagom/Fuzzers: Add a fuzzer for our TIFF decoder
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasChollet committed Oct 29, 2023
1 parent 1ffb0d1 commit db8f11b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Meta/Lagom/Fuzzers/FuzzTIFFLoader.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (c) 2023, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/

#include <LibGfx/ImageFormats/TIFFLoader.h>
#include <stdio.h>

extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
{
auto decoder_or_error = Gfx::TIFFImageDecoderPlugin::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
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ set(FUZZER_TARGETS
SQLParser
Tar
TGALoader
TIFFLoader
TTF
TinyVGLoader
URL
Expand Down Expand Up @@ -126,6 +127,7 @@ set(FUZZER_DEPENDENCIES_ShellPosix LibShell)
set(FUZZER_DEPENDENCIES_SQLParser LibSQL)
set(FUZZER_DEPENDENCIES_Tar LibArchive)
set(FUZZER_DEPENDENCIES_TGALoader LibGfx)
set(FUZZER_DEPENDENCIES_TIFFLoader LibGfx)
set(FUZZER_DEPENDENCIES_TTF LibGfx)
set(FUZZER_DEPENDENCIES_TinyVGLoader LibGfx)
set(FUZZER_DEPENDENCIES_UTF16BEDecoder LibTextCodec)
Expand Down
1 change: 1 addition & 0 deletions Userland/Utilities/test-fuzz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
T(SQLParser) \
T(Tar) \
T(TGALoader) \
T(TIFFLoader) \
T(TTF) \
T(TinyVGLoader) \
T(URL) \
Expand Down

0 comments on commit db8f11b

Please sign in to comment.