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