OLD | NEW |
| (Empty) |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include <stddef.h> | |
6 #include <stdint.h> | |
7 | |
8 #include <algorithm> | |
9 #include <string> | |
10 #include <vector> | |
11 | |
12 #include "libxml/parser.h" | |
13 #include "libxml/tree.h" | |
14 #include "libxml/xmlversion.h" | |
15 | |
16 | |
17 void ignore (void * ctx, const char * msg, ...) { | |
18 // Error handler to avoid spam of error messages from libxml parser. | |
19 } | |
20 | |
21 | |
22 // Entry point for LibFuzzer. | |
23 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { | |
24 xmlSetGenericErrorFunc(NULL, &ignore); | |
25 | |
26 std::vector<uint8_t> buffer(size + 1, 0); | |
27 std::copy(data, data + size, buffer.data()); | |
28 | |
29 xmlRegexpPtr x = xmlRegexpCompile(buffer.data()); | |
30 if (x) | |
31 xmlRegFreeRegexp(x); | |
32 | |
33 return 0; | |
34 } | |
OLD | NEW |