1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-01-05 09:17:38 +03:00
libxml2/fuzz/schemaSeed.c
Nick Wellnhofer eac1c7e2e5 Fuzz target for XML Schemas
This only tests the schema parser for now.
2020-06-23 16:20:27 +02:00

35 lines
758 B
C

/*
* xmlSeed.c: Generate the XML seed corpus for fuzzing.
*
* See Copyright for the status of this software.
*/
#include <stdio.h>
#include <libxml/xmlschemas.h>
#include "fuzz.h"
int
main(int argc, char **argv) {
xmlSchemaPtr schema;
xmlSchemaParserCtxtPtr pctxt;
if (argc != 2) {
fprintf(stderr, "Usage: schemaSeed [XSD]\n");
return(1);
}
xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc);
xmlSetExternalEntityLoader(xmlFuzzEntityRecorder);
pctxt = xmlSchemaNewParserCtxt(argv[1]);
xmlSchemaSetParserErrors(pctxt, xmlFuzzErrorFunc, xmlFuzzErrorFunc, NULL);
schema = xmlSchemaParse(pctxt);
xmlSchemaFreeParserCtxt(pctxt);
xmlSchemaFree(schema);
xmlFuzzDataCleanup();
return(0);
}