aboutsummaryrefslogtreecommitdiff
path: root/fuzz/fuzz_ds_bitmap64_fuse.cpp
diff options
context:
space:
mode:
authorLuca Deri <lucaderi@users.noreply.github.com>2024-03-25 08:15:19 +0100
committerGitHub <noreply@github.com>2024-03-25 08:15:19 +0100
commit51f5fc714015c312622ed4ee1820518d26edee65 (patch)
tree9cd1cee32e3fadada62414f1821210fb4bb83b95 /fuzz/fuzz_ds_bitmap64_fuse.cpp
parentbe0fd7444ff714f3c654aca08b3bf151ac801bbf (diff)
Added support for roaring bitmap v3 (#2355)
* Integrated RoaringBitmap v3 * Renamed ndpi_bitmap64 ro ndpi_bitmap64_fuse * Fixes to ndpi_bitmap for new roaring library * Fixes for bitmap serialization * Fixed format * Warning fix * Conversion fix * Warning fix * Added check for roaring v3 support * Updated file name * Updated path * Uses clang-9 (instead of clang-7) for builds * Fixed fuzz_ds_bitmap64_fuse * Fixes nDPI printf handling * Disabled printf * Yet another printf fix * Cleaup * Fx for compiling on older platforms * Fixes for old compilers * Initialization changes * Added compiler check * Fixes for old compilers * Inline function is not static inline * Added missing include
Diffstat (limited to 'fuzz/fuzz_ds_bitmap64_fuse.cpp')
-rw-r--r--fuzz/fuzz_ds_bitmap64_fuse.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/fuzz/fuzz_ds_bitmap64_fuse.cpp b/fuzz/fuzz_ds_bitmap64_fuse.cpp
new file mode 100644
index 000000000..381c16b5c
--- /dev/null
+++ b/fuzz/fuzz_ds_bitmap64_fuse.cpp
@@ -0,0 +1,54 @@
+#include "ndpi_api.h"
+#include "fuzz_common_code.h"
+
+#include <stdint.h>
+#include "fuzzer/FuzzedDataProvider.h"
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+ FuzzedDataProvider fuzzed_data(data, size);
+ u_int16_t i, num_iteration, is_added = 0;
+ ndpi_bitmap64_fuse *b;
+ bool rc;
+ u_int64_t value, value_added;
+
+ /* To allow memory allocation failures */
+ fuzz_set_alloc_callbacks_and_seed(size);
+
+ b = ndpi_bitmap64_fuse_alloc();
+
+ if(fuzzed_data.ConsumeBool())
+ ndpi_bitmap64_fuse_compress(b);
+
+ num_iteration = fuzzed_data.ConsumeIntegral<u_int16_t>();
+ for (i = 0; i < num_iteration; i++) {
+ value = fuzzed_data.ConsumeIntegral<u_int64_t>();
+
+ rc = ndpi_bitmap64_fuse_set(b, value);
+ /* Keep one random entry really added */
+ if (rc == true && is_added == 0 && fuzzed_data.ConsumeBool()) {
+ value_added = value;
+ is_added = 1;
+ }
+ }
+
+ if(fuzzed_data.ConsumeBool())
+ ndpi_bitmap64_fuse_compress(b);
+
+ /* "Random" search */
+ num_iteration = fuzzed_data.ConsumeIntegral<u_int8_t>();
+ for (i = 0; i < num_iteration; i++) {
+ value = fuzzed_data.ConsumeIntegral<u_int64_t>();
+
+ ndpi_bitmap64_fuse_isset(b, value);
+ }
+ /* Search of an added entry */
+ if (is_added) {
+ ndpi_bitmap64_fuse_isset(b, value_added);
+ }
+
+ ndpi_bitmap64_fuse_size(b);
+
+ ndpi_bitmap64_fuse_free(b);
+
+ return 0;
+}