mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:47:45 +00:00
Lagom/Fuzzers: Add fuzzer for PDF document
This commit is contained in:
parent
34cc4803af
commit
91de60d912
3 changed files with 31 additions and 0 deletions
|
@ -352,6 +352,13 @@ if (BUILD_LAGOM)
|
||||||
LIBS LagomJS
|
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
|
# Regex
|
||||||
file(GLOB LIBREGEX_LIBC_SOURCES "../../Userland/Libraries/LibRegex/C/Regex.cpp")
|
file(GLOB LIBREGEX_LIBC_SOURCES "../../Userland/Libraries/LibRegex/C/Regex.cpp")
|
||||||
file(GLOB LIBREGEX_SOURCES CONFIGURE_DEPENDS "../../Userland/Libraries/LibRegex/*.cpp")
|
file(GLOB LIBREGEX_SOURCES CONFIGURE_DEPENDS "../../Userland/Libraries/LibRegex/*.cpp")
|
||||||
|
|
|
@ -33,6 +33,7 @@ add_simple_fuzzer(FuzzPNGLoader LagomGfx)
|
||||||
add_simple_fuzzer(FuzzPBMLoader LagomGfx)
|
add_simple_fuzzer(FuzzPBMLoader LagomGfx)
|
||||||
add_simple_fuzzer(FuzzPGMLoader LagomGfx)
|
add_simple_fuzzer(FuzzPGMLoader LagomGfx)
|
||||||
add_simple_fuzzer(FuzzPPMLoader LagomGfx)
|
add_simple_fuzzer(FuzzPPMLoader LagomGfx)
|
||||||
|
add_simple_fuzzer(FuzzPDF LagomPDF)
|
||||||
add_simple_fuzzer(FuzzQuotedPrintableParser LagomIMAP)
|
add_simple_fuzzer(FuzzQuotedPrintableParser LagomIMAP)
|
||||||
add_simple_fuzzer(FuzzHebrewDecoder LagomTextCodec)
|
add_simple_fuzzer(FuzzHebrewDecoder LagomTextCodec)
|
||||||
add_simple_fuzzer(FuzzHttpRequest LagomHTTP)
|
add_simple_fuzzer(FuzzHttpRequest LagomHTTP)
|
||||||
|
|
23
Meta/Lagom/Fuzzers/FuzzPDF.cpp
Normal file
23
Meta/Lagom/Fuzzers/FuzzPDF.cpp
Normal 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;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue