fuzz: improve fuzzing coverage (#2309)
This commit is contained in:
@@ -465,6 +465,9 @@ char* ndpi_intoav4(unsigned int addr, char* buf, u_int16_t bufLen);
|
||||
|
||||
u_int16_t icmp4_checksum(u_int8_t const * const buf, size_t len);
|
||||
|
||||
ndpi_risk_enum ndpi_network_risk_ptree_match(struct ndpi_detection_module_struct *ndpi_str,
|
||||
struct in_addr *pin /* network byte order */);
|
||||
|
||||
int load_protocols_file_fd(struct ndpi_detection_module_struct *ndpi_mod, FILE *fd);
|
||||
int load_categories_file_fd(struct ndpi_detection_module_struct *ndpi_str, FILE *fd, void *user_data);
|
||||
int load_malicious_sha1_file_fd(struct ndpi_detection_module_struct *ndpi_str, FILE *fd);
|
||||
|
||||
+14
-4
@@ -2603,6 +2603,9 @@ ndpi_risk_enum ndpi_network_risk_ptree_match(struct ndpi_detection_module_struct
|
||||
ndpi_prefix_t prefix;
|
||||
ndpi_patricia_node_t *node;
|
||||
|
||||
if(!ndpi_str || !ndpi_str->ip_risk_ptree)
|
||||
return(NDPI_NO_RISK);
|
||||
|
||||
/* Make sure all in network byte order otherwise compares wont work */
|
||||
ndpi_fill_prefix_v4(&prefix, pin, 32, ((ndpi_patricia_tree_t *) ndpi_str->ip_risk_ptree)->maxbits);
|
||||
node = ndpi_patricia_search_best(ndpi_str->ip_risk_ptree, &prefix);
|
||||
@@ -4918,11 +4921,15 @@ int load_category_file_fd(struct ndpi_detection_module_struct *ndpi_str,
|
||||
*/
|
||||
int ndpi_load_categories_dir(struct ndpi_detection_module_struct *ndpi_str,
|
||||
char *dir_path) {
|
||||
DIR *dirp = opendir(dir_path);
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
int failed_files = 0;
|
||||
int num_loaded = 0;
|
||||
|
||||
if(!ndpi_str || !dir_path)
|
||||
return(0);
|
||||
|
||||
dirp = opendir(dir_path);
|
||||
if (dirp == NULL)
|
||||
return(0);
|
||||
|
||||
@@ -11102,9 +11109,12 @@ char *ndpi_get_config(struct ndpi_detection_module_struct *ndpi_str,
|
||||
NDPI_LOG_DBG(ndpi_str, "Get [%s][%s]\n", proto, param);
|
||||
|
||||
for(c = &cfg_params[0]; c && c->param; c++) {
|
||||
if(((proto == NULL && c->proto == NULL) ||
|
||||
(proto && c->proto && strcmp(proto, c->proto) == 0)) &&
|
||||
strcmp(param, c->param) == 0) {
|
||||
if((((proto == NULL && c->proto == NULL) ||
|
||||
(proto && c->proto && strcmp(proto, c->proto) == 0)) &&
|
||||
strcmp(param, c->param) == 0) ||
|
||||
(proto && c->proto &&
|
||||
strcmp(c->proto, "$PROTO_NAME_OR_ID") == 0 &&
|
||||
strcmp(param, c->param) == 0)) {
|
||||
|
||||
return cfg_ops[c->type].fn_get((void *)((char *)&ndpi_str->cfg + c->offset), proto, buf, buf_len);
|
||||
}
|
||||
|
||||
@@ -2955,13 +2955,8 @@ u_int8_t ndpi_check_flow_risk_exceptions(struct ndpi_detection_module_struct *nd
|
||||
return(1);
|
||||
break;
|
||||
|
||||
case NDPI_MAX_RISK_PARAM_ID:
|
||||
/* Nothing to do, just avoid warnings */
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("nDPI [%s:%u] Ignored risk parameter id %u\n",
|
||||
__FILE__, __LINE__, params[i].id);
|
||||
NDPI_LOG_ERR(ndpi_str, "Ignored risk parameter id %u\n", params[i].id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,8 +53,6 @@ static void check_content_type_and_change_protocol(struct ndpi_detection_module_
|
||||
struct ndpi_packet_struct *packet = &ndpi_struct->packet;
|
||||
int i, left = packet->payload_packet_len-x;
|
||||
|
||||
if(left <= 0) return;
|
||||
|
||||
for(i=0; jabber_strings[i].string != NULL; i++) {
|
||||
if(ndpi_strnstr((const char*)&packet->payload[x], jabber_strings[i].string, left) != NULL) {
|
||||
ndpi_int_jabber_add_connection(ndpi_struct, flow, jabber_strings[i].ndpi_protocol, NDPI_CONFIDENCE_DPI);
|
||||
|
||||
Reference in New Issue
Block a user