| * regexp.c: a libFuzzer target to test the regexp module. |
| * See Copyright for the status of this software. |
| #include <libxml/xmlregexp.h> |
| LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED, |
| char ***argv ATTRIBUTE_UNUSED) { |
| xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc); |
| LLVMFuzzerTestOneInput(const char *data, size_t size) { |
| char *str[2] = { NULL, NULL }; |
| numStrings = xmlFuzzExtractStrings(data, size, str, 2); |
| /* CUR_SCHAR doesn't handle invalid UTF-8 and may cause infinite loops. */ |
| if (xmlCheckUTF8(BAD_CAST str[0]) != 0) { |
| regexp = xmlRegexpCompile(BAD_CAST str[0]); |
| /* xmlRegexpExec has pathological performance in too many cases. */ |
| if ((regexp != NULL) && (numStrings >= 2)) { |
| xmlRegexpExec(regexp, BAD_CAST str[1]); |
| xmlRegFreeRegexp(regexp); |