equal
deleted
inserted
replaced
8 #include <iostream> |
8 #include <iostream> |
9 #include <string> |
9 #include <string> |
10 |
10 |
11 extern "C" { |
11 extern "C" { |
12 |
12 |
13 static PyCodeObject *code; |
13 static PYCODETYPE *code; |
14 |
14 |
15 extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) |
15 extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) |
16 { |
16 { |
17 contrib::initpy(*argv[0]); |
17 contrib::initpy(*argv[0]); |
18 code = (PyCodeObject *)Py_CompileString(R"py( |
18 code = (PYCODETYPE *)Py_CompileString(R"py( |
19 from parsers import ( |
|
20 isasciistr, |
|
21 asciilower, |
|
22 asciiupper, |
|
23 encodedir, |
|
24 pathencode, |
|
25 lowerencode, |
|
26 ) |
|
27 |
|
28 try: |
19 try: |
29 for fn in ( |
20 for fn in ( |
30 isasciistr, |
21 parsers.isasciistr, |
31 asciilower, |
22 parsers.asciilower, |
32 asciiupper, |
23 parsers.asciiupper, |
33 encodedir, |
24 parsers.encodedir, |
34 pathencode, |
25 parsers.pathencode, |
35 lowerencode, |
26 parsers.lowerencode, |
36 ): |
27 ): |
37 try: |
28 try: |
38 fn(data) |
29 fn(data) |
39 except UnicodeDecodeError: |
30 except UnicodeDecodeError: |
40 pass # some functions emit this exception |
31 pass # some functions emit this exception |
51 pass |
42 pass |
52 # uncomment this print if you're editing this Python code |
43 # uncomment this print if you're editing this Python code |
53 # to debug failures. |
44 # to debug failures. |
54 # print(e) |
45 # print(e) |
55 )py", |
46 )py", |
56 "fuzzer", Py_file_input); |
47 "fuzzer", Py_file_input); |
57 if (!code) { |
48 if (!code) { |
58 std::cerr << "failed to compile Python code!" << std::endl; |
49 std::cerr << "failed to compile Python code!" << std::endl; |
59 } |
50 } |
60 return 0; |
51 return 0; |
61 } |
52 } |