• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 The PDFium Authors
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 "core/fxcrt/compiler_specific.h"
9 #include "core/fxcrt/fx_safe_types.h"
10 #include "core/fxcrt/fx_string.h"
11 #include "fxjs/xfa/cfxjse_formcalc_context.h"
12 #include "testing/fuzzers/pdfium_fuzzer_util.h"
13 #include "testing/fuzzers/xfa_process_state.h"
14 
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)15 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
16   auto* state = static_cast<XFAProcessState*>(FPDF_GetFuzzerPerProcessState());
17   // SAFETY: required from fuzzer.
18   WideString input =
19       WideString::FromUTF8(UNSAFE_BUFFERS(ByteStringView(data, size)));
20   CFXJSE_FormCalcContext::Translate(state->GetHeap(), input.AsStringView());
21   state->ForceGCAndPump();
22   return 0;
23 }
24