aboutsummaryrefslogtreecommitdiff
path: root/fuzz/fuzz_filecfg_config.c
diff options
context:
space:
mode:
authorIvan Nardi <12729895+IvanNardi@users.noreply.github.com>2024-01-20 16:14:41 +0100
committerGitHub <noreply@github.com>2024-01-20 16:14:41 +0100
commit42d23cff6a87825e6d3bc8e81080e6a9102f7709 (patch)
tree8987bfac24ff24de845e1a6ae369513c3567740e /fuzz/fuzz_filecfg_config.c
parent8651ce981149a73df6f2d9d64218ef58a4479c46 (diff)
config: follow-up (#2268)
Some changes in the parameters names. Add a fuzzer to fuzz the configuration file format. Add the infrastructure to configuratin callbacks. Add an helper to map LRU cache indexes to names.
Diffstat (limited to 'fuzz/fuzz_filecfg_config.c')
-rw-r--r--fuzz/fuzz_filecfg_config.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/fuzz/fuzz_filecfg_config.c b/fuzz/fuzz_filecfg_config.c
new file mode 100644
index 000000000..6a096d75e
--- /dev/null
+++ b/fuzz/fuzz_filecfg_config.c
@@ -0,0 +1,27 @@
+#include "ndpi_api.h"
+#include "ndpi_private.h"
+#include "fuzz_common_code.h"
+
+int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+ struct ndpi_detection_module_struct *ndpi_struct;
+ FILE *fd;
+ NDPI_PROTOCOL_BITMASK all;
+
+ /* To allow memory allocation failures */
+ fuzz_set_alloc_callbacks_and_seed(size);
+
+ ndpi_struct = ndpi_init_detection_module();
+ NDPI_BITMASK_SET_ALL(all);
+ ndpi_set_protocol_detection_bitmask2(ndpi_struct, &all);
+
+ ndpi_set_config(ndpi_struct, NULL, "log.level", "3");
+ ndpi_set_config(ndpi_struct, "all", "log", "1");
+
+ fd = buffer_to_file(data, size);
+ load_config_file_fd(ndpi_struct, fd);
+ if(fd)
+ fclose(fd);
+
+ ndpi_exit_detection_module(ndpi_struct);
+ return 0;
+}