mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2024-12-24 21:33:51 +03:00
fuzz: Disable catalogs
The catalogs API doesn't report OOM errors. It's basically impossible to use it safely in its current form.
This commit is contained in:
parent
ca5965d594
commit
30d839776a
@ -16,6 +16,7 @@ LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED,
|
|||||||
xmlInitParser();
|
xmlInitParser();
|
||||||
#ifdef LIBXML_CATALOG_ENABLED
|
#ifdef LIBXML_CATALOG_ENABLED
|
||||||
xmlInitializeCatalog();
|
xmlInitializeCatalog();
|
||||||
|
xmlCatalogSetDefaults(XML_CATA_ALLOW_NONE);
|
||||||
#endif
|
#endif
|
||||||
xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc);
|
xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc);
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED,
|
|||||||
xmlInitParser();
|
xmlInitParser();
|
||||||
#ifdef LIBXML_CATALOG_ENABLED
|
#ifdef LIBXML_CATALOG_ENABLED
|
||||||
xmlInitializeCatalog();
|
xmlInitializeCatalog();
|
||||||
|
xmlCatalogSetDefaults(XML_CATA_ALLOW_NONE);
|
||||||
#endif
|
#endif
|
||||||
xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc);
|
xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc);
|
||||||
xmlSetExternalEntityLoader(xmlFuzzEntityLoader);
|
xmlSetExternalEntityLoader(xmlFuzzEntityLoader);
|
||||||
|
@ -18,6 +18,7 @@ LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED,
|
|||||||
xmlInitParser();
|
xmlInitParser();
|
||||||
#ifdef LIBXML_CATALOG_ENABLED
|
#ifdef LIBXML_CATALOG_ENABLED
|
||||||
xmlInitializeCatalog();
|
xmlInitializeCatalog();
|
||||||
|
xmlCatalogSetDefaults(XML_CATA_ALLOW_NONE);
|
||||||
#endif
|
#endif
|
||||||
xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc);
|
xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc);
|
||||||
xmlSetExternalEntityLoader(xmlFuzzEntityLoader);
|
xmlSetExternalEntityLoader(xmlFuzzEntityLoader);
|
||||||
|
@ -19,6 +19,7 @@ LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED,
|
|||||||
xmlInitParser();
|
xmlInitParser();
|
||||||
#ifdef LIBXML_CATALOG_ENABLED
|
#ifdef LIBXML_CATALOG_ENABLED
|
||||||
xmlInitializeCatalog();
|
xmlInitializeCatalog();
|
||||||
|
xmlCatalogSetDefaults(XML_CATA_ALLOW_NONE);
|
||||||
#endif
|
#endif
|
||||||
xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc);
|
xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc);
|
||||||
xmlSetExternalEntityLoader(xmlFuzzEntityLoader);
|
xmlSetExternalEntityLoader(xmlFuzzEntityLoader);
|
||||||
|
@ -19,6 +19,7 @@ LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED,
|
|||||||
xmlInitParser();
|
xmlInitParser();
|
||||||
#ifdef LIBXML_CATALOG_ENABLED
|
#ifdef LIBXML_CATALOG_ENABLED
|
||||||
xmlInitializeCatalog();
|
xmlInitializeCatalog();
|
||||||
|
xmlCatalogSetDefaults(XML_CATA_ALLOW_NONE);
|
||||||
#endif
|
#endif
|
||||||
xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc);
|
xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc);
|
||||||
xmlSetExternalEntityLoader(xmlFuzzEntityLoader);
|
xmlSetExternalEntityLoader(xmlFuzzEntityLoader);
|
||||||
|
@ -13,6 +13,10 @@ LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED,
|
|||||||
char ***argv ATTRIBUTE_UNUSED) {
|
char ***argv ATTRIBUTE_UNUSED) {
|
||||||
xmlFuzzMemSetup();
|
xmlFuzzMemSetup();
|
||||||
xmlInitParser();
|
xmlInitParser();
|
||||||
|
#ifdef LIBXML_CATALOG_ENABLED
|
||||||
|
xmlInitializeCatalog();
|
||||||
|
xmlCatalogSetDefaults(XML_CATA_ALLOW_NONE);
|
||||||
|
#endif
|
||||||
xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc);
|
xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
6
parser.c
6
parser.c
@ -5382,6 +5382,12 @@ xmlParseCatalogPI(xmlParserCtxtPtr ctxt, const xmlChar *catalog) {
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (URL != NULL) {
|
if (URL != NULL) {
|
||||||
|
/*
|
||||||
|
* Unfortunately, the catalog API doesn't report OOM errors.
|
||||||
|
* xmlGetLastError isn't very helpful since we don't know
|
||||||
|
* where the last error came from. We'd have to reset it
|
||||||
|
* before this call and restore it afterwards.
|
||||||
|
*/
|
||||||
ctxt->catalogs = xmlCatalogAddLocal(ctxt->catalogs, URL);
|
ctxt->catalogs = xmlCatalogAddLocal(ctxt->catalogs, URL);
|
||||||
xmlFree(URL);
|
xmlFree(URL);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user