Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Unified Diff: testing/libfuzzer/pdf_xml_fuzzer.cc

Issue 2481933003: Compile fuzzer sources in standalone builds. (try 2) (Closed)
Patch Set: Fix signed comparison issues Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « testing/libfuzzer/pdf_fm2js_fuzzer.cc ('k') | testing/libfuzzer/xfa_codec_fuzzer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: testing/libfuzzer/pdf_xml_fuzzer.cc
diff --git a/testing/libfuzzer/pdf_xml_fuzzer.cc b/testing/libfuzzer/pdf_xml_fuzzer.cc
index 7bd0b66b37be033e3bfed7e16b21e4073cc90d6c..91b4d6026cf9ce7653e986ca5c4a56b1aabaf1eb 100644
--- a/testing/libfuzzer/pdf_xml_fuzzer.cc
+++ b/testing/libfuzzer/pdf_xml_fuzzer.cc
@@ -4,11 +4,12 @@
#include <cstddef>
#include <cstdint>
-#include <limits>
#include <memory>
#include "core/fxcrt/fx_basic.h"
+#include "core/fxcrt/fx_safe_types.h"
#include "core/fxcrt/fx_system.h"
+#include "third_party/base/ptr_util.h"
#include "xfa/fde/xml/fde_xml_imp.h"
#include "xfa/fxfa/parser/cxfa_xml_parser.h"
#include "xfa/fxfa/parser/cxfa_widetextread.h"
@@ -45,17 +46,18 @@ CFDE_XMLNode* XFA_FDEExtension_GetDocumentNode(
} // namespace
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()));
std::unique_ptr<IFX_Stream, ReleaseDeleter<IFX_Stream>> stream(
new CXFA_WideTextRead(input));
if (!stream)
return 0;
- std::unique_ptr<CFDE_XMLDoc> doc(new CFDE_XMLDoc);
+ std::unique_ptr<CFDE_XMLDoc> doc = pdfium::MakeUnique<CFDE_XMLDoc>();
std::unique_ptr<CFDE_XMLParser, ReleaseDeleter<CFDE_XMLParser>> parser(
new CXFA_XMLParser(doc->GetRoot(), stream.get()));
« no previous file with comments | « testing/libfuzzer/pdf_fm2js_fuzzer.cc ('k') | testing/libfuzzer/xfa_codec_fuzzer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698