fuzz: add fuzzer testing nDPI (initial) configurations (#1830)

The goal of this fuzzer is to test init and deinit of the library, with
different configurations. In details:
* random memory allocation failures, even during init phase
* random `ndpi_init_prefs` parameter of `ndpi_init_detection_module()`
* random LRU caches sizes
* random bitmask of enabled protocols
* random parameters of `ndpi_set_detection_preferences()`
* random initialization of opportunistic TLS
* random load/don't load of configuration files

This new fuzzer is a C++ file, because it uses `FuzzedDataProvider`
class (see
https://github.com/google/fuzzing/blob/master/docs/split-inputs.md).
Note that the (existing) fuzzers need to be linked with C++ compiler
anyway, so this new fuzzer doesn't add any new requirements.
This commit is contained in:
Ivan Nardi
2022-12-23 19:07:13 +01:00
committed by GitHub
parent 3de76812d9
commit 560280e6f0
13 changed files with 310 additions and 60 deletions
+2 -1
View File
@@ -264,9 +264,10 @@ extern "C" {
*
* @par ndpi_struct = the detection module
* @par detection_bitmask = the protocol bitmask to set
* @return 0 if ok, -1 if error
*
*/
void ndpi_set_protocol_detection_bitmask2(struct ndpi_detection_module_struct *ndpi_struct,
int ndpi_set_protocol_detection_bitmask2(struct ndpi_detection_module_struct *ndpi_struct,
const NDPI_PROTOCOL_BITMASK * detection_bitmask);
/**
+5 -1
View File
@@ -218,7 +218,11 @@
# define NDPI_LOG_DBG2(...) {}
# else
# define NDPI_LOG(proto, mod, log_level, args...) { /* printf(args); */ }
# define NDPI_LOG_ERR(mod, args...) { printf(args); }
# ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
# define NDPI_LOG_ERR(mod, args...) { printf(args); }
# else
# define NDPI_LOG_ERR(mod, args...) { /* printf(args); */ }
# endif
# define NDPI_LOG_INFO(mod, args...) { /* printf(args); */ }
# define NDPI_LOG_DBG(mod, args...) { /* printf(args); */ }
# define NDPI_LOG_DBG2(mod, args...) { /* printf(args); */ }