1 /*
2 * fuzz.h: Common functions and macros for fuzzing.
3 *
4 * See Copyright for the status of this software.
5 */
6
7 #ifndef __XML_FUZZERCOMMON_H__
8 #define __XML_FUZZERCOMMON_H__
9
10 #include <stddef.h>
11 #include <stdio.h>
12 #include <libxml/parser.h>
13
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17
18 #if defined(LIBXML_HTML_ENABLED)
19 #define HAVE_HTML_FUZZER
20 #endif
21 #if defined(LIBXML_REGEXP_ENABLED)
22 #define HAVE_REGEXP_FUZZER
23 #endif
24 #if defined(LIBXML_SCHEMAS_ENABLED)
25 #define HAVE_SCHEMA_FUZZER
26 #endif
27 #if 1
28 #define HAVE_URI_FUZZER
29 #endif
30 #if defined(LIBXML_VALID_ENABLED)
31 #define HAVE_VALID_FUZZER
32 #endif
33 #if defined(LIBXML_XINCLUDE_ENABLED)
34 #define HAVE_XINCLUDE_FUZZER
35 #endif
36 #if 1
37 #define HAVE_XML_FUZZER
38 #endif
39 #if defined(LIBXML_XPTR_ENABLED)
40 #define HAVE_XPATH_FUZZER
41 #endif
42
43 int
44 LLVMFuzzerInitialize(int *argc, char ***argv);
45
46 int
47 LLVMFuzzerTestOneInput(const char *data, size_t size);
48
49 void
50 xmlFuzzErrorFunc(void *ctx ATTRIBUTE_UNUSED, const char *msg ATTRIBUTE_UNUSED,
51 ...);
52
53 void
54 xmlFuzzMemSetup(void);
55
56 void
57 xmlFuzzMemSetLimit(size_t limit);
58
59 int
60 xmlFuzzMallocFailed(void);
61
62 void
63 xmlFuzzDataInit(const char *data, size_t size);
64
65 void
66 xmlFuzzDataCleanup(void);
67
68 void
69 xmlFuzzWriteInt(FILE *out, size_t v, int size);
70
71 size_t
72 xmlFuzzReadInt(int size);
73
74 const char *
75 xmlFuzzReadRemaining(size_t *size);
76
77 void
78 xmlFuzzWriteString(FILE *out, const char *str);
79
80 const char *
81 xmlFuzzReadString(size_t *size);
82
83 void
84 xmlFuzzReadEntities(void);
85
86 const char *
87 xmlFuzzMainUrl(void);
88
89 const char *
90 xmlFuzzMainEntity(size_t *size);
91
92 xmlParserInputPtr
93 xmlFuzzEntityLoader(const char *URL, const char *ID, xmlParserCtxtPtr ctxt);
94
95 char *
96 xmlSlurpFile(const char *path, size_t *size);
97
98 #ifdef __cplusplus
99 }
100 #endif
101
102 #endif /* __XML_FUZZERCOMMON_H__ */
103