mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-01-05 09:17:38 +03:00
9086988ffa
Remove the libfuzzer max_len option which doesn't apply to other fuzzing engines. Enforce the maximum length directly in the fuzz targets. For the xml target, lower the maximum when expanding entities to avoid timeout and OOM errors.
40 lines
883 B
C
40 lines
883 B
C
/*
|
|
* schema.c: a libFuzzer target to test the XML Schema processor.
|
|
*
|
|
* See Copyright for the status of this software.
|
|
*/
|
|
|
|
#include <libxml/xmlschemas.h>
|
|
#include "fuzz.h"
|
|
|
|
int
|
|
LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED,
|
|
char ***argv ATTRIBUTE_UNUSED) {
|
|
xmlInitParser();
|
|
xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc);
|
|
xmlSetExternalEntityLoader(xmlFuzzEntityLoader);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
LLVMFuzzerTestOneInput(const char *data, size_t size) {
|
|
xmlSchemaParserCtxtPtr pctxt;
|
|
|
|
if (size > 50000)
|
|
return(0);
|
|
|
|
xmlFuzzDataInit(data, size);
|
|
xmlFuzzReadEntities();
|
|
|
|
pctxt = xmlSchemaNewParserCtxt(xmlFuzzMainUrl());
|
|
xmlSchemaSetParserErrors(pctxt, xmlFuzzErrorFunc, xmlFuzzErrorFunc, NULL);
|
|
xmlSchemaFree(xmlSchemaParse(pctxt));
|
|
xmlSchemaFreeParserCtxt(pctxt);
|
|
|
|
xmlFuzzDataCleanup();
|
|
|
|
return(0);
|
|
}
|
|
|