VirtualBox

source: vbox/trunk/src/libs/libxml2-2.12.6/fuzz/schema.c@ 104582

最後變更 在這個檔案從104582是 104106,由 vboxsync 提交於 10 月 前

libxml2-2.9.14: Applied and adjusted our libxml2 changes to 2.9.14. bugref:10640

  • 屬性 svn:eol-style 設為 native
檔案大小: 1.1 KB
 
1/*
2 * schema.c: a libFuzzer target to test the XML Schema processor.
3 *
4 * See Copyright for the status of this software.
5 */
6
7#include <libxml/catalog.h>
8#include <libxml/xmlschemas.h>
9#include "fuzz.h"
10
11int
12LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED,
13 char ***argv ATTRIBUTE_UNUSED) {
14 xmlFuzzMemSetup();
15 xmlInitParser();
16#ifdef LIBXML_CATALOG_ENABLED
17 xmlInitializeCatalog();
18#endif
19 xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc);
20 xmlSetExternalEntityLoader(xmlFuzzEntityLoader);
21
22 return 0;
23}
24
25int
26LLVMFuzzerTestOneInput(const char *data, size_t size) {
27 xmlSchemaParserCtxtPtr pctxt;
28 size_t maxAlloc;
29
30 if (size > 50000)
31 return(0);
32
33 maxAlloc = xmlFuzzReadInt(4) % (size + 1);
34
35 xmlFuzzDataInit(data, size);
36 xmlFuzzReadEntities();
37
38 xmlFuzzMemSetLimit(maxAlloc);
39 pctxt = xmlSchemaNewParserCtxt(xmlFuzzMainUrl());
40 xmlSchemaSetParserErrors(pctxt, xmlFuzzErrorFunc, xmlFuzzErrorFunc, NULL);
41 xmlSchemaFree(xmlSchemaParse(pctxt));
42 xmlSchemaFreeParserCtxt(pctxt);
43
44 xmlFuzzMemSetLimit(0);
45 xmlFuzzDataCleanup();
46 xmlResetLastError();
47
48 return(0);
49}
50
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette