diff options
author | Brendan Coles <bcoles@gmail.com> | 2021-10-30 12:05:13 +0000 |
---|---|---|
committer | Brian Gianforcaro <b.gianfo@gmail.com> | 2021-10-30 10:33:56 -0700 |
commit | 91de60d91280b71a8c9af5307ec271784ece9376 (patch) | |
tree | dcbe0b2351be559a6e15e5421a3195c4721064ae /Meta/Lagom/Fuzzers | |
parent | 34cc4803afc974d498183b2c07729b382360e484 (diff) | |
download | serenity-91de60d91280b71a8c9af5307ec271784ece9376.zip |
Lagom/Fuzzers: Add fuzzer for PDF document
Diffstat (limited to 'Meta/Lagom/Fuzzers')
-rw-r--r-- | Meta/Lagom/Fuzzers/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Meta/Lagom/Fuzzers/FuzzPDF.cpp | 23 |
2 files changed, 24 insertions, 0 deletions
diff --git a/Meta/Lagom/Fuzzers/CMakeLists.txt b/Meta/Lagom/Fuzzers/CMakeLists.txt index ffd286a893..96430496ce 100644 --- a/Meta/Lagom/Fuzzers/CMakeLists.txt +++ b/Meta/Lagom/Fuzzers/CMakeLists.txt @@ -33,6 +33,7 @@ add_simple_fuzzer(FuzzPNGLoader LagomGfx) add_simple_fuzzer(FuzzPBMLoader LagomGfx) add_simple_fuzzer(FuzzPGMLoader LagomGfx) add_simple_fuzzer(FuzzPPMLoader LagomGfx) +add_simple_fuzzer(FuzzPDF LagomPDF) add_simple_fuzzer(FuzzQuotedPrintableParser LagomIMAP) add_simple_fuzzer(FuzzHebrewDecoder LagomTextCodec) add_simple_fuzzer(FuzzHttpRequest LagomHTTP) diff --git a/Meta/Lagom/Fuzzers/FuzzPDF.cpp b/Meta/Lagom/Fuzzers/FuzzPDF.cpp new file mode 100644 index 0000000000..733fcb7e5c --- /dev/null +++ b/Meta/Lagom/Fuzzers/FuzzPDF.cpp @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2021, the SerenityOS developers. + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include <LibPDF/Document.h> +#include <stdint.h> + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + ReadonlyBytes bytes { data, size }; + auto doc = PDF::Document::create(bytes); + + if (doc) { + auto pages = doc->get_page_count(); + for (size_t i = 0; i < pages; ++i) { + (void)doc->get_page(i); + } + } + + return 0; +} |