• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifdef __cplusplus
2 extern "C" {
3 #endif
4 
5 #include <inttypes.h>
6 #include <libxml.h>
7 #include <libxml/relaxng.h>
8 #include <libxml/xmlerror.h>
9 #include <stdlib.h>
10 
11 #include <libhfuzz/libhfuzz.h>
12 
13 FILE* null_file = NULL;
14 
LLVMFuzzerInitialize(int * argc,char *** argv)15 int LLVMFuzzerInitialize(int* argc, char*** argv) {
16     null_file = fopen("/dev/null", "w");
17     return 0;
18 }
19 
LLVMFuzzerTestOneInput(const uint8_t * buf,size_t len)20 int LLVMFuzzerTestOneInput(const uint8_t* buf, size_t len) {
21     xmlDocPtr p = xmlReadMemory((const char*)buf, len, "http://www.google.com", "UTF-8",
22         XML_PARSE_RECOVER | XML_PARSE_NONET);
23     if (!p) {
24         return 0;
25     }
26     xmlDocFormatDump(null_file, p, 1);
27     xmlFreeDoc(p);
28     return 0;
29 }
30 
31 #ifdef __cplusplus
32 }
33 #endif
34