Coverage Report

Created: 2023-03-26 06:22

/src/hostap/tests/fuzzing/fuzzer-common.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Common helper functions for fuzzing tools
3
 * Copyright (c) 2019, Jouni Malinen <j@w1.fi>
4
 *
5
 * This software may be distributed under the terms of the BSD license.
6
 * See README for more details.
7
 */
8
9
#include "utils/includes.h"
10
11
#include "utils/common.h"
12
13
14
void wpa_fuzzer_set_debug_level(void)
15
1.05k
{
16
1.05k
  static int first = 1;
17
18
1.05k
  if (first) {
19
1
    char *env;
20
21
1
    first = 0;
22
1
    env = getenv("WPADEBUG");
23
1
    if (env)
24
0
      wpa_debug_level = atoi(env);
25
1
    else
26
1
      wpa_debug_level = MSG_ERROR + 1;
27
28
1
    wpa_debug_show_keys = 1;
29
1
  }
30
1.05k
}
31
32
33
#ifndef TEST_LIBFUZZER
34
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
35
36
int main(int argc, char *argv[])
37
{
38
  char *data;
39
  size_t len;
40
41
  if (argc < 2) {
42
    printf("usage: %s <file>\n", argv[0]);
43
    return -1;
44
  }
45
46
  data = os_readfile(argv[1], &len);
47
  if (!data) {
48
    printf("Could not read '%s'\n", argv[1]);
49
    return -1;
50
  }
51
52
  LLVMFuzzerTestOneInput((const uint8_t *) data, len);
53
  os_free(data);
54
  return 0;
55
}
56
#endif /* !TEST_LIBFUZZER */