mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:57:43 +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
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