fuzz: extend fuzzers coverage (#1952)
This commit is contained in:
@@ -45,6 +45,10 @@
|
||||
|
||||
#include "ndpi_includes.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* constants */
|
||||
#define NUM_PARAMETERS_SPLT_LOGREG 208
|
||||
#define NUM_PARAMETERS_BD_LOGREG 464
|
||||
@@ -89,4 +93,8 @@ u_int64_t ndpi_timeval_to_milliseconds(pkt_timeval ts);
|
||||
u_int64_t ndpi_timeval_to_microseconds(pkt_timeval ts);
|
||||
void ndpi_log_timestamp(char *log_ts, u_int32_t log_ts_len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NDPI_CLASSIFY_H */
|
||||
|
||||
@@ -95,7 +95,7 @@ extern "C" {
|
||||
struct ndpi_flow_struct *flow);
|
||||
|
||||
extern u_int16_t ndpi_check_for_email_address(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
u_int16_t counter);
|
||||
u_int16_t counter);
|
||||
|
||||
extern void ndpi_int_change_category(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow,
|
||||
|
||||
@@ -43,6 +43,9 @@ ndpi_port_range* ndpi_build_default_ports(ndpi_port_range *ports,
|
||||
u_int16_t portE);
|
||||
|
||||
/* TCP/UDP protocols */
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
u_int ndpi_search_tcp_or_udp_raw(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow,
|
||||
u_int8_t protocol,
|
||||
|
||||
@@ -1096,6 +1096,7 @@ int ndpi_hw_init(struct ndpi_hw_struct *hw,
|
||||
|
||||
if((hw->s = (double*)ndpi_calloc(hw->params.num_season_periods, sizeof(double))) == NULL) {
|
||||
ndpi_free(hw->y);
|
||||
hw->y = NULL;
|
||||
return(-1);
|
||||
}
|
||||
|
||||
@@ -1213,8 +1214,10 @@ void ndpi_hw_reset(struct ndpi_hw_struct *hw) {
|
||||
hw->num_values = 0;
|
||||
hw->u = hw->v = hw->sum_square_error = 0;
|
||||
|
||||
memset(&hw->y, 0, (hw->params.num_season_periods * sizeof(u_int64_t)));
|
||||
memset(&hw->s, 0, (hw->params.num_season_periods * sizeof(double)));
|
||||
if(hw->y)
|
||||
memset(hw->y, 0, (hw->params.num_season_periods * sizeof(u_int64_t)));
|
||||
if(hw->s)
|
||||
memset(hw->s, 0, (hw->params.num_season_periods * sizeof(double)));
|
||||
}
|
||||
|
||||
/* ********************************************************************************* */
|
||||
|
||||
@@ -268,10 +268,12 @@ ndpi_merge_splt_arrays (const uint16_t *pkt_len, const pkt_timeval *pkt_time,
|
||||
uint16_t *merged_lens, uint16_t *merged_times)
|
||||
{
|
||||
int s,r;
|
||||
pkt_timeval ts_start = { 0, 0 }; /* initialize to avoid spurious warnings */
|
||||
pkt_timeval ts_start;
|
||||
pkt_timeval tmp, tmp_r;
|
||||
pkt_timeval start_m;
|
||||
|
||||
ndpi_timer_clear(&ts_start);
|
||||
|
||||
if(r_idx + s_idx == 0) {
|
||||
return ;
|
||||
} else if(r_idx == 0) {
|
||||
@@ -677,7 +679,7 @@ ndpi_timeval_to_microseconds(pkt_timeval ts)
|
||||
{
|
||||
u_int64_t sec = ts.tv_sec;
|
||||
u_int64_t usec = ts.tv_usec;
|
||||
return usec + sec * 1000 * 1000;;
|
||||
return usec + sec * 1000 * 1000;
|
||||
}
|
||||
|
||||
/* **************************************** */
|
||||
|
||||
+8
-4
@@ -2287,7 +2287,7 @@ u_int16_t ndpi_network_ptree_match(struct ndpi_detection_module_struct *ndpi_str
|
||||
ndpi_prefix_t prefix;
|
||||
ndpi_patricia_node_t *node;
|
||||
|
||||
if(!ndpi_str->protocols_ptree)
|
||||
if(!ndpi_str || !ndpi_str->protocols_ptree)
|
||||
return(NDPI_PROTOCOL_UNKNOWN);
|
||||
|
||||
if(ndpi_str->ndpi_num_custom_protocols == 0) {
|
||||
@@ -2318,7 +2318,7 @@ u_int16_t ndpi_network_port_ptree_match(struct ndpi_detection_module_struct *ndp
|
||||
ndpi_prefix_t prefix;
|
||||
ndpi_patricia_node_t *node;
|
||||
|
||||
if(!ndpi_str->protocols_ptree)
|
||||
if(!ndpi_str || !ndpi_str->protocols_ptree)
|
||||
return(NDPI_PROTOCOL_UNKNOWN);
|
||||
|
||||
if(ndpi_str->ndpi_num_custom_protocols == 0) {
|
||||
@@ -7498,8 +7498,12 @@ void ndpi_parse_packet_line_info_any(struct ndpi_detection_module_struct *ndpi_s
|
||||
|
||||
u_int16_t ndpi_check_for_email_address(struct ndpi_detection_module_struct *ndpi_str,
|
||||
u_int16_t counter) {
|
||||
struct ndpi_packet_struct *packet = &ndpi_str->packet;
|
||||
struct ndpi_packet_struct *packet;
|
||||
|
||||
if(!ndpi_str)
|
||||
return(0);
|
||||
|
||||
packet = &ndpi_str->packet;
|
||||
NDPI_LOG_DBG2(ndpi_str, "called ndpi_check_for_email_address\n");
|
||||
|
||||
if(packet->payload_packet_len > counter && ((packet->payload[counter] >= 'a' && packet->payload[counter] <= 'z') ||
|
||||
@@ -8983,7 +8987,7 @@ const char *ndpi_get_l4_proto_name(ndpi_l4_proto_info proto) {
|
||||
|
||||
ndpi_l4_proto_info ndpi_get_l4_proto_info(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
u_int16_t ndpi_proto_id) {
|
||||
if(ndpi_proto_id < ndpi_struct->ndpi_num_supported_protocols) {
|
||||
if(ndpi_struct && ndpi_proto_id < ndpi_struct->ndpi_num_supported_protocols) {
|
||||
u_int16_t idx = ndpi_struct->proto_defaults[ndpi_proto_id].protoIdx;
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_SIZE bm = ndpi_struct->callback_buffer[idx].ndpi_selection_bitmask;
|
||||
|
||||
|
||||
+4
-16
@@ -2018,39 +2018,30 @@ const char* ndpi_risk2str(ndpi_risk_enum risk) {
|
||||
|
||||
case NDPI_POSSIBLE_EXPLOIT:
|
||||
return("Possible Exploit");
|
||||
break;
|
||||
|
||||
case NDPI_TLS_CERTIFICATE_ABOUT_TO_EXPIRE:
|
||||
return("TLS Cert About To Expire");
|
||||
break;
|
||||
|
||||
case NDPI_PUNYCODE_IDN:
|
||||
return("IDN Domain Name");
|
||||
break;
|
||||
|
||||
case NDPI_ERROR_CODE_DETECTED:
|
||||
return("Error Code");
|
||||
break;
|
||||
|
||||
case NDPI_HTTP_CRAWLER_BOT:
|
||||
return("Crawler/Bot");
|
||||
break;
|
||||
|
||||
case NDPI_ANONYMOUS_SUBSCRIBER:
|
||||
return("Anonymous Subscriber");
|
||||
break;
|
||||
|
||||
case NDPI_UNIDIRECTIONAL_TRAFFIC:
|
||||
return("Unidirectional Traffic");
|
||||
break;
|
||||
|
||||
case NDPI_HTTP_OBSOLETE_SERVER:
|
||||
return("HTTP Obsolete Server");
|
||||
break;
|
||||
|
||||
case NDPI_PERIODIC_FLOW:
|
||||
return("Periodic Flow");
|
||||
break;
|
||||
|
||||
case NDPI_MINOR_ISSUES:
|
||||
return("Minor Issues");
|
||||
@@ -2070,27 +2061,21 @@ const char* ndpi_severity2str(ndpi_risk_severity s) {
|
||||
switch(s) {
|
||||
case NDPI_RISK_LOW:
|
||||
return("Low");
|
||||
break;
|
||||
|
||||
case NDPI_RISK_MEDIUM:
|
||||
return("Medium");
|
||||
break;
|
||||
|
||||
case NDPI_RISK_HIGH:
|
||||
return("High");
|
||||
break;
|
||||
|
||||
case NDPI_RISK_SEVERE:
|
||||
return("Severe");
|
||||
break;
|
||||
|
||||
case NDPI_RISK_CRITICAL:
|
||||
return("Critical");
|
||||
break;
|
||||
|
||||
case NDPI_RISK_EMERGENCY:
|
||||
return("Emergency");
|
||||
break;
|
||||
}
|
||||
|
||||
return("");
|
||||
@@ -2367,7 +2352,7 @@ static u_int8_t ndpi_check_hostname_risk_exception(struct ndpi_detection_module_
|
||||
ndpi_automa *automa = &ndpi_str->host_risk_mask_automa;
|
||||
u_int8_t ret = 0;
|
||||
|
||||
if(automa->ac_automa) {
|
||||
if(automa && automa->ac_automa) {
|
||||
AC_TEXT_t ac_input_text;
|
||||
AC_REP_t match;
|
||||
|
||||
@@ -2880,6 +2865,9 @@ u_int8_t ndpi_check_flow_risk_exceptions(struct ndpi_detection_module_struct *nd
|
||||
ndpi_risk_params params[]) {
|
||||
u_int i;
|
||||
|
||||
if(!ndpi_str)
|
||||
return(0);
|
||||
|
||||
for(i=0; i<num_params; i++) {
|
||||
switch(params[i].id) {
|
||||
case NDPI_PARAM_HOSTNAME:
|
||||
|
||||
Reference in New Issue
Block a user