• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include <stddef.h>
6 #include <stdint.h>
7 
8 #include "public/fpdf_formfill.h"
9 #include "testing/fuzzers/pdfium_fuzzer_helper.h"
10 #include "testing/fuzzers/pdfium_xfa_lpm_fuzz_stub.h"
11 
12 class PDFiumLpmFuzzStub : public PDFiumFuzzerHelper {
13  public:
14   PDFiumLpmFuzzStub() = default;
15   ~PDFiumLpmFuzzStub() override = default;
16 
GetFormCallbackVersion() const17   int GetFormCallbackVersion() const override { return 2; }
18   // Allow fuzzer to fuzz XFA but don't require it to fuzz.
OnFormFillEnvLoaded(FPDF_DOCUMENT doc)19   bool OnFormFillEnvLoaded(FPDF_DOCUMENT doc) override {
20     FPDF_LoadXFA(doc);
21     return true;
22   }
23 };
24 
PdfiumXFALPMFuzzStub(const char * pdf,size_t size)25 void PdfiumXFALPMFuzzStub(const char* pdf, size_t size) {
26   PDFiumLpmFuzzStub fuzz_stub;
27   fuzz_stub.RenderPdf(pdf, size);
28 }
29