Home | History | Annotate | Download | only in libxml2
      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 
     15 int LLVMFuzzerInitialize(int* argc, char*** argv)
     16 {
     17     null_file = fopen("/dev/null", "w");
     18     return 0;
     19 }
     20 
     21 int LLVMFuzzerTestOneInput(const uint8_t* buf, size_t len)
     22 {
     23     xmlDocPtr p = xmlReadMemory((const char*)buf, len, "http://www.google.com", "UTF-8", XML_PARSE_RECOVER | XML_PARSE_NONET);
     24     if (!p) {
     25         return 0;
     26     }
     27     xmlDocFormatDump(null_file, p, 1);
     28     xmlFreeDoc(p);
     29     return 0;
     30 }
     31 
     32 #ifdef __cplusplus
     33 }
     34 #endif
     35