/src/yara/tests/oss-fuzz/dex_fuzzer.cc
Line | Count | Source (jump to first uncovered line) |
1 | | #include <stddef.h> |
2 | | #include <stdint.h> |
3 | | #include <yara.h> |
4 | | |
5 | | |
6 | | YR_RULES* rules = NULL; |
7 | | |
8 | | |
9 | | extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) |
10 | 1 | { |
11 | 1 | YR_COMPILER* compiler; |
12 | | |
13 | 1 | if (yr_initialize() != ERROR_SUCCESS) |
14 | 0 | return 0; |
15 | | |
16 | 1 | if (yr_compiler_create(&compiler) != ERROR_SUCCESS) |
17 | 0 | return 0; |
18 | | |
19 | 1 | if (yr_compiler_add_string(compiler, "import \"dex\"", NULL) == 0) |
20 | 1 | yr_compiler_get_rules(compiler, &rules); |
21 | | |
22 | 1 | yr_compiler_destroy(compiler); |
23 | | |
24 | 1 | return 0; |
25 | 1 | } |
26 | | |
27 | | |
28 | | int callback( |
29 | | YR_SCAN_CONTEXT* context, |
30 | | int message, |
31 | | void* message_data, |
32 | | void* user_data) |
33 | 0 | { |
34 | 0 | return CALLBACK_CONTINUE; |
35 | 0 | } |
36 | | |
37 | | |
38 | | extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) |
39 | 0 | { |
40 | 0 | if (rules == NULL) |
41 | 0 | return 0; |
42 | | |
43 | 0 | yr_rules_scan_mem( |
44 | 0 | rules, data, size, SCAN_FLAGS_NO_TRYCATCH, callback, NULL, 0); |
45 | |
|
46 | 0 | return 0; |
47 | 0 | } |