mirror of
				https://gitlab.gnome.org/GNOME/libxml2.git
				synced 2025-10-30 10:45:36 +03:00 
			
		
		
		
	- Add more calls to xmlInitializeCatalog. - Call xmlResetLastError after fuzzing each input.
		
			
				
	
	
		
			45 lines
		
	
	
		
			1001 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
		
			1001 B
		
	
	
	
		
			C
		
	
	
	
	
	
| /*
 | |
|  * schema.c: a libFuzzer target to test the XML Schema processor.
 | |
|  *
 | |
|  * See Copyright for the status of this software.
 | |
|  */
 | |
| 
 | |
| #include <libxml/catalog.h>
 | |
| #include <libxml/xmlschemas.h>
 | |
| #include "fuzz.h"
 | |
| 
 | |
| int
 | |
| LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED,
 | |
|                      char ***argv ATTRIBUTE_UNUSED) {
 | |
|     xmlInitParser();
 | |
| #ifdef LIBXML_CATALOG_ENABLED
 | |
|     xmlInitializeCatalog();
 | |
| #endif
 | |
|     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();
 | |
|     xmlResetLastError();
 | |
| 
 | |
|     return(0);
 | |
| }
 | |
| 
 |