fuzz: add a new fuzzer to test serialization/deserialization code (#1876)
Autodetecting the needed buffer size is quite complex (especially with float/double values) so it is mandatory to properly check for `ndpi_snprintf` truncation. These issues have been undetected so far probably because the default buffer is big enough for all common cases. Add an example of usage of `ndpi_deserialize_clone_all()` (taken from `ntopng`)
This commit is contained in:
@@ -18,7 +18,7 @@ jobs:
|
||||
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
|
||||
with:
|
||||
oss-fuzz-project-name: 'ndpi'
|
||||
fuzz-seconds: 1500
|
||||
fuzz-seconds: 1600
|
||||
dry-run: false
|
||||
sanitizer: ${{ matrix.sanitizer }}
|
||||
- name: Check Crash (fails when a crash is detected)
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
/fuzz/fuzz_alg_ses_des
|
||||
/fuzz/fuzz_config
|
||||
/fuzz/fuzz_community_id
|
||||
/fuzz/fuzz_serialization
|
||||
/fuzz/fuzz_ds_patricia
|
||||
/fuzz/fuzz_ds_libcache
|
||||
/fuzz/fuzz_ds_tree
|
||||
@@ -70,6 +71,7 @@
|
||||
/fuzz/fuzz_quic_get_crypto_data_seed_corpus.zip
|
||||
/fuzz/fuzz_config_seed_corpus.zip
|
||||
/fuzz/fuzz_community_id_seed_corpus.zip
|
||||
/fuzz/fuzz_serialization_seed_corpus.zip
|
||||
/fuzz/fuzz_alg_ses_des_seed_corpus.zip
|
||||
/fuzz/fuzz_alg_bins_seed_corpus.zip
|
||||
/fuzz/fuzz_alg_hll_seed_corpus.zip
|
||||
|
||||
+23
-2
@@ -1,4 +1,4 @@
|
||||
bin_PROGRAMS = fuzz_process_packet fuzz_ndpi_reader fuzz_ndpi_reader_alloc_fail fuzz_quic_get_crypto_data fuzz_config fuzz_community_id
|
||||
bin_PROGRAMS = fuzz_process_packet fuzz_ndpi_reader fuzz_ndpi_reader_alloc_fail fuzz_quic_get_crypto_data fuzz_config fuzz_community_id fuzz_serialization
|
||||
#Alghoritms
|
||||
bin_PROGRAMS += fuzz_alg_bins fuzz_alg_hll fuzz_alg_hw_rsi_outliers_da fuzz_alg_jitter fuzz_alg_ses_des
|
||||
#Data structures
|
||||
@@ -86,6 +86,21 @@ fuzz_community_id_LINK=$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CXX) @NDPI_CFLAGS@ $(AM_CXXFLAGS) $(CXXFLAGS) \
|
||||
$(fuzz_community_id_LDFLAGS) @NDPI_LDFLAGS@ $(LDFLAGS) -o $@
|
||||
|
||||
fuzz_serialization_SOURCES = fuzz_serialization.cpp fuzz_common_code.c
|
||||
fuzz_serialization_CXXFLAGS = @NDPI_CFLAGS@ $(CXXFLAGS) -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
||||
fuzz_serialization_CFLAGS = @NDPI_CFLAGS@ $(CXXFLAGS) -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
||||
fuzz_serialization_LDADD = ../src/lib/libndpi.a $(ADDITIONAL_LIBS)
|
||||
fuzz_serialization_LDFLAGS = $(LIBS)
|
||||
if HAS_FUZZLDFLAGS
|
||||
fuzz_serialization_CXXFLAGS += $(LIB_FUZZING_ENGINE)
|
||||
fuzz_serialization_CFLAGS += $(LIB_FUZZING_ENGINE)
|
||||
fuzz_serialization_LDFLAGS += $(LIB_FUZZING_ENGINE)
|
||||
endif
|
||||
# force usage of CXX for linker
|
||||
fuzz_serialization_LINK=$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CXX) @NDPI_CFLAGS@ $(AM_CXXFLAGS) $(CXXFLAGS) \
|
||||
$(fuzz_serialization_LDFLAGS) @NDPI_LDFLAGS@ $(LDFLAGS) -o $@
|
||||
|
||||
fuzz_alg_bins_SOURCES = fuzz_alg_bins.cpp fuzz_common_code.c
|
||||
fuzz_alg_bins_CXXFLAGS = @NDPI_CFLAGS@ $(CXXFLAGS) -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
||||
fuzz_alg_bins_CFLAGS = @NDPI_CFLAGS@ $(CXXFLAGS) -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
||||
@@ -242,6 +257,11 @@ files_corpus_fuzz_config := $(wildcard corpus/fuzz_config/*)
|
||||
fuzz_config_seed_corpus.zip: $(files_corpus_fuzz_config)
|
||||
zip -j fuzz_config_seed_corpus.zip $(files_corpus_fuzz_config)
|
||||
|
||||
files_corpus_fuzz_serialization := $(wildcard corpus/fuzz_serialization/*)
|
||||
|
||||
fuzz_serialization_seed_corpus.zip: $(files_corpus_fuzz_serialization)
|
||||
zip -j fuzz_serialization_seed_corpus.zip $(files_corpus_fuzz_serialization)
|
||||
|
||||
files_corpus_fuzz_community_id := $(wildcard corpus/fuzz_community_id/*)
|
||||
|
||||
fuzz_community_id_seed_corpus.zip: $(files_corpus_fuzz_community_id)
|
||||
@@ -292,7 +312,7 @@ files_corpus_fuzz_ds_tree := $(wildcard corpus/fuzz_ds_tree/*)
|
||||
fuzz_ds_tree_seed_corpus.zip: $(files_corpus_fuzz_ds_tree)
|
||||
zip -j fuzz_ds_tree_seed_corpus.zip $(files_corpus_fuzz_ds_tree)
|
||||
|
||||
corpus: fuzz_ndpi_reader_seed_corpus.zip fuzz_ndpi_reader_alloc_fail_seed_corpus.zip fuzz_quic_get_crypto_data_seed_corpus.zip fuzz_config_seed_corpus.zip fuzz_ds_patricia_seed_corpus.zip fuzz_ds_ahocorasick_seed_corpus.zip fuzz_alg_ses_des_seed_corpus.zip fuzz_alg_hw_rsi_outliers_da_seed_corpus.zip fuzz_alg_bins_seed_corpus.zip fuzz_alg_hll_seed_corpus.zip fuzz_alg_jitter_seed_corpus.zip fuzz_ds_libcache_seed_corpus.zip fuzz_community_id_seed_corpus.zip fuzz_ds_tree_seed_corpus.zip
|
||||
corpus: fuzz_ndpi_reader_seed_corpus.zip fuzz_ndpi_reader_alloc_fail_seed_corpus.zip fuzz_quic_get_crypto_data_seed_corpus.zip fuzz_config_seed_corpus.zip fuzz_ds_patricia_seed_corpus.zip fuzz_ds_ahocorasick_seed_corpus.zip fuzz_alg_ses_des_seed_corpus.zip fuzz_alg_hw_rsi_outliers_da_seed_corpus.zip fuzz_alg_bins_seed_corpus.zip fuzz_alg_hll_seed_corpus.zip fuzz_alg_jitter_seed_corpus.zip fuzz_ds_libcache_seed_corpus.zip fuzz_community_id_seed_corpus.zip fuzz_ds_tree_seed_corpus.zip fuzz_serialization_seed_corpus.zip
|
||||
|
||||
#Create dictionaries exactly as expected by oss-fuzz.
|
||||
#This way, if we need to change/update/add something,
|
||||
@@ -311,6 +331,7 @@ distdir:
|
||||
-o -name '*.dict' \
|
||||
-o -path './corpus/fuzz_quic_get_crypto_data/*' \
|
||||
-o -path './corpus/fuzz_config/*' \
|
||||
-o -path './corpus/fuzz_serialization/*' \
|
||||
-o -path './corpus/fuzz_community_id/*' \
|
||||
-o -path './corpus/fuzz_alg_ses_des/*' \
|
||||
-o -path './corpus/fuzz_alg_bins/*' \
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
R�0-
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
�0�{Шp(�'}��F
|
||||
@@ -0,0 +1 @@
|
||||
ト���
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
�
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
„K!i @`¨1צְ ¨GH we<ׁ�7@¿|£�™׳:vה/א&mַ}§9‹ױ‘©צמ÷p%ײפ׳ױ
|
||||
@@ -0,0 +1 @@
|
||||
®0ПОЩ
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,3 @@
|
||||
ƒ
|
||||
ú}ppú}
|
||||
í_çƒÁa‘†¬]C%�
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
0�{�uLLLLLOLLLLLLL���
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
}怱縫児繝チa怠クtツリァ�Pィサル04
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
ヒc�
|
||||
@@ -0,0 +1 @@
|
||||
ƒΑa‘†¬D°�␍η½ Έ���«™=•;0izZXΩ™Κ6�ν_η�Υώ>ύh�{|4¶^iW�δ �ρ€γƒΑa‘†¬]D°C%�
|
||||
@@ -0,0 +1 @@
|
||||
ًلل
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
}™†�…„D–u6ΤRώ�›«Η].…ηzρν
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
в„
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
�0+;;�I5j�@;x��m�
|
||||
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
�
|
||||
]C%�
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
;±e}û"�0ô{ëuêxn¸Ý‹cêÏé�ôÌ^šP*
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
乫�+
|
||||
@@ -0,0 +1 @@
|
||||
*˙
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
0�LLLLLL���
|
||||
@@ -0,0 +1 @@
|
||||
��!9��dD�D��]�4�}�
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
m�
|
||||
@@ -0,0 +1 @@
|
||||
ゾC%�
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
0��
|
||||
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
�
|
||||
棏γャ]C%�
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
���
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user