summaryrefslogtreecommitdiff
path: root/testing/libfuzzer/pdf_fm2js_fuzzer.cc
diff options
context:
space:
mode:
authorthestig <thestig@chromium.org>2016-11-08 12:59:30 -0800
committerCommit bot <commit-bot@chromium.org>2016-11-08 12:59:30 -0800
commit62114cf3d85ee9149b270e02935c98395567f45e (patch)
treebd5a8e1dcaeb47e53c033c30c44f9f2e33bb3dbc /testing/libfuzzer/pdf_fm2js_fuzzer.cc
parentc59fa8895fa6fa8428b9b278eee6f05478ab8f56 (diff)
downloadpdfium-62114cf3d85ee9149b270e02935c98395567f45e.tar.xz
Compile fuzzer sources in standalone builds. (try 2)
- Add a template for fuzzers to remove redundancy. - Sort fuzzers in alphabetical order. Previous attempt: https://codereview.chromium.org/2480043002/ Review-Url: https://codereview.chromium.org/2481933003
Diffstat (limited to 'testing/libfuzzer/pdf_fm2js_fuzzer.cc')
-rw-r--r--testing/libfuzzer/pdf_fm2js_fuzzer.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/testing/libfuzzer/pdf_fm2js_fuzzer.cc b/testing/libfuzzer/pdf_fm2js_fuzzer.cc
index 3e3bfae0d4..ced5e18399 100644
--- a/testing/libfuzzer/pdf_fm2js_fuzzer.cc
+++ b/testing/libfuzzer/pdf_fm2js_fuzzer.cc
@@ -6,15 +6,17 @@
#include <cstdint>
#include "core/fxcrt/fx_basic.h"
+#include "core/fxcrt/fx_safe_types.h"
#include "core/fxcrt/fx_string.h"
#include "xfa/fxfa/fm2js/xfa_program.h"
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
- if (size > std::numeric_limits<FX_STRSIZE>::max())
+ FX_SAFE_STRSIZE safe_size = size;
+ if (!safe_size.IsValid())
return 0;
- CFX_WideString input = CFX_WideString::FromUTF8(
- CFX_ByteStringC(data, static_cast<FX_STRSIZE>(size)));
+ CFX_WideString input =
+ CFX_WideString::FromUTF8(CFX_ByteStringC(data, safe_size.ValueOrDie()));
CXFA_FMProgram program;
if (program.Init(input.AsStringC()) || program.ParseProgram())
return 0;