/src/ndpi/fuzz/fuzz_filecfg_protocols.c
Line | Count | Source |
1 | | #include "ndpi_api.h" |
2 | | #include "ndpi_private.h" |
3 | | #include "fuzz_common_code.h" |
4 | | |
5 | 8.60k | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { |
6 | 8.60k | struct ndpi_detection_module_struct *ndpi_struct; |
7 | 8.60k | FILE *fd; |
8 | | |
9 | | /* To allow memory allocation failures */ |
10 | 8.60k | fuzz_set_alloc_callbacks_and_seed(size); |
11 | | |
12 | 8.60k | ndpi_struct = ndpi_init_detection_module(NULL); |
13 | | |
14 | 8.60k | ndpi_set_config(ndpi_struct, NULL, "log.level", "3"); |
15 | 8.60k | ndpi_set_config(ndpi_struct, "all", "log", "1"); |
16 | | |
17 | 8.60k | fd = buffer_to_file(data, size); |
18 | 8.60k | load_protocols_file_fd(ndpi_struct, fd); |
19 | 8.60k | if(fd) |
20 | 8.60k | fclose(fd); |
21 | | |
22 | 8.60k | ndpi_exit_detection_module(ndpi_struct); |
23 | 8.60k | return 0; |
24 | 8.60k | } |