Coverage Report

Created: 2025-07-23 06:46

/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
9
{
11
9
  YR_COMPILER* compiler;
12
13
9
  if (yr_initialize() != ERROR_SUCCESS)
14
0
    return 0;
15
16
9
  if (yr_compiler_create(&compiler) != ERROR_SUCCESS)
17
0
    return 0;
18
19
9
  if (yr_compiler_add_string(compiler, "import \"dex\"", NULL) == 0)
20
9
    yr_compiler_get_rules(compiler, &rules);
21
22
9
  yr_compiler_destroy(compiler);
23
24
9
  return 0;
25
9
}
26
27
28
int callback(
29
    YR_SCAN_CONTEXT* context,
30
    int message,
31
    void* message_data,
32
    void* user_data)
33
95.8k
{
34
95.8k
  return CALLBACK_CONTINUE;
35
95.8k
}
36
37
38
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
39
25.7k
{
40
25.7k
  if (rules == NULL)
41
0
    return 0;
42
43
25.7k
  yr_rules_scan_mem(
44
25.7k
      rules, data, size, SCAN_FLAGS_NO_TRYCATCH, callback, NULL, 0);
45
46
25.7k
  return 0;
47
25.7k
}