/src/xerces_fuzz_common.cpp
Line | Count | Source |
1 | | /* |
2 | | # |
3 | | # Licensed under the Apache License, Version 2.0 (the "License"); |
4 | | # you may not use this file except in compliance with the License. |
5 | | # You may obtain a copy of the License at |
6 | | # |
7 | | # http://www.apache.org/licenses/LICENSE-2.0 |
8 | | # |
9 | | # Unless required by applicable law or agreed to in writing, software |
10 | | # distributed under the License is distributed on an "AS IS" BASIS, |
11 | | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | | # See the License for the specific language governing permissions and |
13 | | # limitations under the License. |
14 | | # |
15 | | ################################################################################ |
16 | | */ |
17 | | #include "xerces_fuzz_common.h" |
18 | | |
19 | | using namespace xercesc_3_2; |
20 | | static bool initialized = false; |
21 | | |
22 | | void parseInMemory(const uint8_t *Data, size_t Size) |
23 | 8.25k | { |
24 | 8.25k | if (!initialized) |
25 | 1 | { |
26 | 1 | XMLPlatformUtils::Initialize(); |
27 | 1 | initialized = true; |
28 | 1 | } |
29 | 8.25k | SAXParser::ValSchemes valScheme = SAXParser::Val_Auto; |
30 | 8.25k | bool doNamespaces = false; |
31 | 8.25k | bool doSchema = false; |
32 | 8.25k | bool schemaFullChecking = false; |
33 | 8.25k | SAXParser *parser = new SAXParser; |
34 | 8.25k | parser->setValidationScheme(valScheme); |
35 | 8.25k | parser->setDoNamespaces(doNamespaces); |
36 | 8.25k | parser->setDoSchema(doSchema); |
37 | 8.25k | parser->setHandleMultipleImports(true); |
38 | 8.25k | parser->setValidationSchemaFullChecking(schemaFullChecking); |
39 | 8.25k | static const char *gMemBufId = "prodInfo"; |
40 | | |
41 | 8.25k | MemBufInputSource *memBufIS = new MemBufInputSource( |
42 | 8.25k | (const XMLByte *)Data, Size, gMemBufId, false); |
43 | 8.25k | parser->parse(*memBufIS); |
44 | 8.25k | delete parser; |
45 | 8.25k | delete memBufIS; |
46 | | //XMLPlatformUtils::Terminate(); |
47 | 8.25k | } |