mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-08 04:15:23 +03:00
Lagom/Fuzzers: Add fuzzer for PDF document
This commit is contained in:
parent
34cc4803af
commit
91de60d912
Notes:
sideshowbarker
2024-07-18 01:44:33 +09:00
Author: https://github.com/bcoles Commit: https://github.com/SerenityOS/serenity/commit/91de60d9128 Pull-request: https://github.com/SerenityOS/serenity/pull/10705
@ -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")
|
||||
|
@ -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)
|
||||
|
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…
Reference in New Issue
Block a user