aboutsummaryrefslogtreecommitdiff
path: root/fuzz/fuzz_readerutils_parseprotolist.cpp
diff options
context:
space:
mode:
authorIvan Nardi <12729895+IvanNardi@users.noreply.github.com>2025-06-09 09:00:17 +0200
committerGitHub <noreply@github.com>2025-06-09 09:00:17 +0200
commitcbd7136b3480774a10f18744d33d3694ffee221b (patch)
treea9981734e85c500ab4605e913cd6ee8b8197492d /fuzz/fuzz_readerutils_parseprotolist.cpp
parent75395cb264f9bfd38d27ac0ba506acc9eab22e34 (diff)
Remove `NDPI_PROTOCOL_BITMASK`; add a new generic bitmask data structure (#2871)
The main difference is that the memory is allocated at runtime Typical usercase: ``` struct ndpi_bitmask b; ndpi_bitmask_alloc(&b, ndpi_get_num_internal_protocols()); ndpi_bitmask_set(&b, $BIT); ndpi_bitmask_is_set(&b, $BIT); [...] ndpi_bitmask_dealloc(&b); ``` See #2136
Diffstat (limited to 'fuzz/fuzz_readerutils_parseprotolist.cpp')
-rw-r--r--fuzz/fuzz_readerutils_parseprotolist.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/fuzz/fuzz_readerutils_parseprotolist.cpp b/fuzz/fuzz_readerutils_parseprotolist.cpp
index 3d004f74e..3dfcdd0f3 100644
--- a/fuzz/fuzz_readerutils_parseprotolist.cpp
+++ b/fuzz/fuzz_readerutils_parseprotolist.cpp
@@ -19,17 +19,19 @@ int monitoring_enabled = 0;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
FuzzedDataProvider fuzzed_data(data, size);
int inverted_logic;
- NDPI_INTERNAL_PROTOCOL_BITMASK bitmask;
+ struct ndpi_bitmask bitmask;
char *str;
+ ndpi_bitmask_alloc(&bitmask, ndpi_get_num_internal_protocols()); /* Don't make this call to fail...*/
+
/* To allow memory allocation failures */
fuzz_set_alloc_callbacks_and_seed(size);
inverted_logic = size % 2; /* pseudo-random */
if(inverted_logic) {
- NDPI_INTERNAL_PROTOCOL_SET_ALL(bitmask);
+ ndpi_bitmask_set_all(&bitmask);
} else {
- NDPI_INTERNAL_PROTOCOL_RESET(bitmask);
+ ndpi_bitmask_reset(&bitmask);
}
str = (char *)ndpi_malloc(size + 1); /* We need a null-terminated string */
@@ -41,5 +43,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
ndpi_free(str);
}
+
+ ndpi_bitmask_dealloc(&bitmask);
+
return 0;
}