OLD | NEW |
1 // Copyright 2016 The PDFium Authors. All rights reserved. | 1 // Copyright 2016 The PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <cstddef> | 5 #include <cstddef> |
6 #include <cstdint> | 6 #include <cstdint> |
7 #include <limits> | 7 #include <limits> |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "core/fxcrt/include/fx_basic.h" | 10 #include "core/fxcrt/include/fx_basic.h" |
11 #include "core/fxcrt/include/fx_system.h" | 11 #include "core/fxcrt/include/fx_system.h" |
12 #include "xfa/fde/xml/fde_xml_imp.h" | 12 #include "xfa/fde/xml/fde_xml_imp.h" |
13 #include "xfa/fxfa/parser/cxfa_xml_parser.h" | 13 #include "xfa/fxfa/parser/cxfa_xml_parser.h" |
14 #include "xfa/fxfa/parser/xfa_utils.h" | 14 #include "xfa/fxfa/parser/cxfa_widetextread.h" |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 CFDE_XMLNode* XFA_FDEExtension_GetDocumentNode( | 18 CFDE_XMLNode* XFA_FDEExtension_GetDocumentNode( |
19 CFDE_XMLDoc* pXMLDoc, | 19 CFDE_XMLDoc* pXMLDoc, |
20 FX_BOOL bVerifyWellFormness = FALSE) { | 20 FX_BOOL bVerifyWellFormness = FALSE) { |
21 if (!pXMLDoc) { | 21 if (!pXMLDoc) { |
22 return nullptr; | 22 return nullptr; |
23 } | 23 } |
24 CFDE_XMLNode* pXMLFakeRoot = pXMLDoc->GetRoot(); | 24 CFDE_XMLNode* pXMLFakeRoot = pXMLDoc->GetRoot(); |
(...skipping 19 matching lines...) Expand all Loading... |
44 | 44 |
45 } // namespace | 45 } // namespace |
46 | 46 |
47 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { | 47 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
48 if (size > std::numeric_limits<FX_STRSIZE>::max()) | 48 if (size > std::numeric_limits<FX_STRSIZE>::max()) |
49 return 0; | 49 return 0; |
50 | 50 |
51 CFX_WideString input = CFX_WideString::FromUTF8( | 51 CFX_WideString input = CFX_WideString::FromUTF8( |
52 CFX_ByteStringC(data, static_cast<FX_STRSIZE>(size))); | 52 CFX_ByteStringC(data, static_cast<FX_STRSIZE>(size))); |
53 std::unique_ptr<IFX_Stream, ReleaseDeleter<IFX_Stream>> stream( | 53 std::unique_ptr<IFX_Stream, ReleaseDeleter<IFX_Stream>> stream( |
54 XFA_CreateWideTextRead(input)); | 54 new CXFA_WideTextRead(input)); |
55 if (!stream) | 55 if (!stream) |
56 return 0; | 56 return 0; |
57 | 57 |
58 std::unique_ptr<CFDE_XMLDoc> doc(new CFDE_XMLDoc); | 58 std::unique_ptr<CFDE_XMLDoc> doc(new CFDE_XMLDoc); |
59 std::unique_ptr<CFDE_XMLParser, ReleaseDeleter<CFDE_XMLParser>> parser( | 59 std::unique_ptr<CFDE_XMLParser, ReleaseDeleter<CFDE_XMLParser>> parser( |
60 new CXFA_XMLParser(doc->GetRoot(), stream.get())); | 60 new CXFA_XMLParser(doc->GetRoot(), stream.get())); |
61 | 61 |
62 if (!doc->LoadXML(parser.release())) | 62 if (!doc->LoadXML(parser.release())) |
63 return 0; | 63 return 0; |
64 | 64 |
65 int32_t load_result = doc->DoLoad(nullptr); | 65 int32_t load_result = doc->DoLoad(nullptr); |
66 if (load_result < 100) | 66 if (load_result < 100) |
67 return 0; | 67 return 0; |
68 | 68 |
69 (void)XFA_FDEExtension_GetDocumentNode(doc.get()); | 69 (void)XFA_FDEExtension_GetDocumentNode(doc.get()); |
70 return 0; | 70 return 0; |
71 } | 71 } |
OLD | NEW |