/src/parse_target_proto.cpp
Line | Count | Source (jump to first uncovered line) |
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 | | #include "xmlProtoConverter.h" |
19 | | |
20 | | #include "xercesc/framework/MemBufInputSource.hpp" |
21 | | #include "xercesc/parsers/SAXParser.hpp" |
22 | | #include "xercesc/util/OutOfMemoryException.hpp" |
23 | | |
24 | | #include "genfiles/xml.pb.h" |
25 | | |
26 | | #include "src/libfuzzer/libfuzzer_macro.h" |
27 | | |
28 | | #include <iostream> |
29 | | |
30 | | namespace { |
31 | 0 | void ignore(void* ctx, const char* msg, ...) {} |
32 | | |
33 | | template <class T, class D> |
34 | | std::unique_ptr<T, D> MakeUnique(T* obj, D del) { |
35 | | return {obj, del}; |
36 | | } |
37 | | } |
38 | | |
39 | | using namespace xercesc_3_2; |
40 | | |
41 | 8.25k | DEFINE_PROTO_FUZZER(const xmlProtoFuzzer::XmlDocument& xmlDocument) { |
42 | 8.25k | std::string xmlData = xmlProtoFuzzer::ProtoConverter().protoToString(xmlDocument); |
43 | 8.25k | parseInMemory((const uint8_t *)xmlData.c_str(), xmlData.size()); |
44 | 8.25k | } |