VirtualBox

source: vbox/trunk/src/libs/libxml2-2.12.6/fuzz/regexp.c@ 105635

最後變更 在這個檔案從105635是 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 * regexp.c: a libFuzzer target to test the regexp module.
3 *
4 * See Copyright for the status of this software.
5 */
6
7#include <stdio.h>
8#include <stdlib.h>
9#include <libxml/xmlregexp.h>
10#include "fuzz.h"
11
12int
13LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED,
14 char ***argv ATTRIBUTE_UNUSED) {
15 xmlFuzzMemSetup();
16 xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc);
17
18 return 0;
19}
20
21int
22LLVMFuzzerTestOneInput(const char *data, size_t size) {
23 xmlRegexpPtr regexp;
24 size_t maxAlloc;
25 const char *str1;
26
27 if (size > 200)
28 return(0);
29
30 xmlFuzzDataInit(data, size);
31 maxAlloc = xmlFuzzReadInt(4) % (size * 8 + 1);
32 str1 = xmlFuzzReadString(NULL);
33
34 xmlFuzzMemSetLimit(maxAlloc);
35 regexp = xmlRegexpCompile(BAD_CAST str1);
36 if (xmlFuzzMallocFailed() && regexp != NULL) {
37 fprintf(stderr, "malloc failure not reported\n");
38 abort();
39 }
40 /* xmlRegexpExec has pathological performance in too many cases. */
41#if 0
42 xmlRegexpExec(regexp, BAD_CAST str2);
43#endif
44 xmlRegFreeRegexp(regexp);
45
46 xmlFuzzMemSetLimit(0);
47 xmlFuzzDataCleanup();
48 xmlResetLastError();
49
50 return 0;
51}
52
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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