aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/ndpi_analyze.c7
-rw-r--r--src/lib/ndpi_classify.c6
-rw-r--r--src/lib/ndpi_main.c12
-rw-r--r--src/lib/ndpi_utils.c20
4 files changed, 21 insertions, 24 deletions
diff --git a/src/lib/ndpi_analyze.c b/src/lib/ndpi_analyze.c
index 178097b9f..346e65a48 100644
--- a/src/lib/ndpi_analyze.c
+++ b/src/lib/ndpi_analyze.c
@@ -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)));
}
/* ********************************************************************************* */
diff --git a/src/lib/ndpi_classify.c b/src/lib/ndpi_classify.c
index f1037411d..3dba2207e 100644
--- a/src/lib/ndpi_classify.c
+++ b/src/lib/ndpi_classify.c
@@ -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;
}
/* **************************************** */
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c
index 6b2210ec1..4d83def4d 100644
--- a/src/lib/ndpi_main.c
+++ b/src/lib/ndpi_main.c
@@ -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;
diff --git a/src/lib/ndpi_utils.c b/src/lib/ndpi_utils.c
index 8f89ef7bf..343c5b0f0 100644
--- a/src/lib/ndpi_utils.c
+++ b/src/lib/ndpi_utils.c
@@ -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: