Fix/improve fuzzing (#2426)
This commit is contained in:
@@ -774,6 +774,7 @@ distdir:
|
|||||||
-o -name '*.cpp' \
|
-o -name '*.cpp' \
|
||||||
-o -name '*.options' \
|
-o -name '*.options' \
|
||||||
-o -name 'ipv4_addresses.txt' \
|
-o -name 'ipv4_addresses.txt' \
|
||||||
|
-o -name 'ipv6_addresses.txt' \
|
||||||
-o -name 'bd_param.txt' \
|
-o -name 'bd_param.txt' \
|
||||||
-o -name 'splt_param.txt' \
|
-o -name 'splt_param.txt' \
|
||||||
-o -name 'random_list.list' \
|
-o -name 'random_list.list' \
|
||||||
|
|||||||
@@ -49,6 +49,12 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Some higher level functions */
|
||||||
|
ndpi_load_ipv4_ptree_file(t, "ipv4_addresses.txt", NDPI_PROTOCOL_TLS);
|
||||||
|
ndpi_load_ipv4_ptree_file(t, "invalid_filename", NDPI_PROTOCOL_TLS);
|
||||||
|
ndpi_load_ipv6_ptree_file(t, "ipv6_addresses.txt", NDPI_PROTOCOL_TLS);
|
||||||
|
ndpi_load_ipv6_ptree_file(t, "invalid_filename", NDPI_PROTOCOL_TLS);
|
||||||
|
|
||||||
/* Random search */
|
/* Random search */
|
||||||
num_iteration = fuzzed_data.ConsumeIntegral<u_int8_t>();
|
num_iteration = fuzzed_data.ConsumeIntegral<u_int8_t>();
|
||||||
for (i = 0; i < num_iteration; i++) {
|
for (i = 0; i < num_iteration; i++) {
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
#Random list of ipv6 addresses
|
||||||
|
|
||||||
|
2001:db8:3333:4444:5555:6666:7777:8888
|
||||||
|
2001:a:b:c::/64
|
||||||
|
ff06::c3
|
||||||
+7
-1
@@ -2735,7 +2735,7 @@ static ndpi_patricia_node_t* add_to_ptree(ndpi_patricia_tree_t *tree, int family
|
|||||||
/* ******************************************* */
|
/* ******************************************* */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Load a file containing IPv4 addresses in CIDR format as 'protocol_id'
|
Load a file containing IPv4 OR IPv6 addresses in CIDR format as 'protocol_id'
|
||||||
|
|
||||||
Return: the number of entries loaded or -1 in case of error
|
Return: the number of entries loaded or -1 in case of error
|
||||||
*/
|
*/
|
||||||
@@ -2808,6 +2808,8 @@ int ndpi_load_ptree_file(ndpi_patricia_tree_t *ptree,
|
|||||||
|
|
||||||
int ndpi_load_ipv4_ptree_file(ndpi_ptree_t *ptree, const char *path,
|
int ndpi_load_ipv4_ptree_file(ndpi_ptree_t *ptree, const char *path,
|
||||||
u_int16_t protocol_id) {
|
u_int16_t protocol_id) {
|
||||||
|
if(!ptree)
|
||||||
|
return -1;
|
||||||
return(ndpi_load_ptree_file(ptree->v4, path, true /* IPv4 */, protocol_id));
|
return(ndpi_load_ptree_file(ptree->v4, path, true /* IPv4 */, protocol_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2815,6 +2817,8 @@ int ndpi_load_ipv4_ptree_file(ndpi_ptree_t *ptree, const char *path,
|
|||||||
|
|
||||||
int ndpi_load_ipv6_ptree_file(ndpi_ptree_t *ptree, const char *path,
|
int ndpi_load_ipv6_ptree_file(ndpi_ptree_t *ptree, const char *path,
|
||||||
u_int16_t protocol_id) {
|
u_int16_t protocol_id) {
|
||||||
|
if(!ptree)
|
||||||
|
return -1;
|
||||||
return(ndpi_load_ptree_file(ptree->v6, path, false /* IPv6 */, protocol_id));
|
return(ndpi_load_ptree_file(ptree->v6, path, false /* IPv6 */, protocol_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2827,6 +2831,8 @@ int ndpi_load_ipv6_ptree_file(ndpi_ptree_t *ptree, const char *path,
|
|||||||
*/
|
*/
|
||||||
int ndpi_load_ipv4_ptree(struct ndpi_detection_module_struct *ndpi_str,
|
int ndpi_load_ipv4_ptree(struct ndpi_detection_module_struct *ndpi_str,
|
||||||
const char *path, u_int16_t protocol_id) {
|
const char *path, u_int16_t protocol_id) {
|
||||||
|
if(!ndpi_str)
|
||||||
|
return -1;
|
||||||
return(ndpi_load_ptree_file(ndpi_str->protocols_ptree,
|
return(ndpi_load_ptree_file(ndpi_str->protocols_ptree,
|
||||||
path, true /* is_ipv4 */,
|
path, true /* is_ipv4 */,
|
||||||
protocol_id));
|
protocol_id));
|
||||||
|
|||||||
+1
-1
@@ -61,7 +61,7 @@ cp example/ja3_fingerprints.csv $OUT/
|
|||||||
cp example/sha1_fingerprints.csv $OUT/
|
cp example/sha1_fingerprints.csv $OUT/
|
||||||
cp example/config.txt $OUT/
|
cp example/config.txt $OUT/
|
||||||
cp lists/public_suffix_list.dat $OUT/
|
cp lists/public_suffix_list.dat $OUT/
|
||||||
cp fuzz/ipv4_addresses.txt $OUT/
|
cp fuzz/ipv*_addresses.txt $OUT/
|
||||||
cp fuzz/bd_param.txt $OUT/
|
cp fuzz/bd_param.txt $OUT/
|
||||||
cp fuzz/splt_param.txt $OUT/
|
cp fuzz/splt_param.txt $OUT/
|
||||||
cp fuzz/random_list.list $OUT/
|
cp fuzz/random_list.list $OUT/
|
||||||
|
|||||||
Reference in New Issue
Block a user