summaryrefslogtreecommitdiff
path: root/testing/libfuzzer/pdf_xml_fuzzer.cc
diff options
context:
space:
mode:
Diffstat (limited to 'testing/libfuzzer/pdf_xml_fuzzer.cc')
-rw-r--r--testing/libfuzzer/pdf_xml_fuzzer.cc38
1 files changed, 6 insertions, 32 deletions
diff --git a/testing/libfuzzer/pdf_xml_fuzzer.cc b/testing/libfuzzer/pdf_xml_fuzzer.cc
index d8010f90f8..3a2889421f 100644
--- a/testing/libfuzzer/pdf_xml_fuzzer.cc
+++ b/testing/libfuzzer/pdf_xml_fuzzer.cc
@@ -14,37 +14,6 @@
#include "core/fxcrt/xml/cfx_xmlparser.h"
#include "third_party/base/ptr_util.h"
-namespace {
-
-CFX_XMLNode* XFA_FDEExtension_GetDocumentNode(
- CFX_XMLDoc* pXMLDoc,
- bool bVerifyWellFormness = false) {
- if (!pXMLDoc) {
- return nullptr;
- }
- CFX_XMLNode* pXMLFakeRoot = pXMLDoc->GetRoot();
- for (CFX_XMLNode* pXMLNode =
- pXMLFakeRoot->GetNodeItem(CFX_XMLNode::FirstChild);
- pXMLNode; pXMLNode = pXMLNode->GetNodeItem(CFX_XMLNode::NextSibling)) {
- if (pXMLNode->GetType() == FX_XMLNODE_Element) {
- if (bVerifyWellFormness) {
- for (CFX_XMLNode* pNextNode =
- pXMLNode->GetNodeItem(CFX_XMLNode::NextSibling);
- pNextNode;
- pNextNode = pNextNode->GetNodeItem(CFX_XMLNode::NextSibling)) {
- if (pNextNode->GetType() == FX_XMLNODE_Element) {
- return nullptr;
- }
- }
- }
- return pXMLNode;
- }
- }
- return nullptr;
-}
-
-} // namespace
-
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
FX_SAFE_SIZE_T safe_size = size;
if (!safe_size.IsValid())
@@ -60,6 +29,11 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
if (doc->DoLoad() < 100)
return 0;
- (void)XFA_FDEExtension_GetDocumentNode(doc.get());
+ CFX_XMLNode* pXMLFakeRoot = doc->GetRoot();
+ for (CFX_XMLNode* pXMLNode = pXMLFakeRoot->GetFirstChild(); pXMLNode;
+ pXMLNode = pXMLNode->GetNextSibling()) {
+ if (pXMLNode->GetType() == FX_XMLNODE_Element)
+ break;
+ }
return 0;
}