Lagom/Fuzzers: Add fuzzer for PDF document

This commit is contained in:
Brendan Coles 2021-10-30 12:05:13 +00:00 committed by Brian Gianforcaro
parent 34cc4803af
commit 91de60d912
Notes: sideshowbarker 2024-07-18 01:44:33 +09:00
3 changed files with 31 additions and 0 deletions

View File

@ -352,6 +352,13 @@ if (BUILD_LAGOM)
LIBS LagomJS
)
# PDF
file(GLOB LIBPDF_SOURCES CONFIGURE_DEPENDS "../../Userland/Libraries/LibPDF/*.cpp")
lagom_lib(PDF pdf
SOURCES ${LIBPDF_SOURCES}
LIBS LagomGfx LagomIPC LagomTextCodec
)
# Regex
file(GLOB LIBREGEX_LIBC_SOURCES "../../Userland/Libraries/LibRegex/C/Regex.cpp")
file(GLOB LIBREGEX_SOURCES CONFIGURE_DEPENDS "../../Userland/Libraries/LibRegex/*.cpp")

View File

@ -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)

View File

@ -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;
}