Merge pull request #879 from IvanNardi/warnings

Fix some compilation warnings
This commit is contained in:
Luca Deri
2020-04-21 19:23:57 +02:00
committed by GitHub
7 changed files with 17 additions and 12 deletions
-6
View File
@@ -53,7 +53,6 @@ double get_flow_score(ndpi_norm_value* scores, int n_metrics){
/* ********************************** */
double Ddos_score(struct ndpi_flow_info* flow){
double f = (double)flow->first_seen/1000.0, l = (double)flow->last_seen/1000.0;
int n_metrics = 6;
ndpi_norm_value* scores = malloc(n_metrics * sizeof(ndpi_norm_value));
/* pktlen_c_to_s_avg */
@@ -105,7 +104,6 @@ double Ddos_score(struct ndpi_flow_info* flow){
}
double Dos_goldeneye_score(struct ndpi_flow_info* flow){
double f = (double)flow->first_seen/1000.0, l = (double)flow->last_seen/1000.0;
int n_metrics = 6;
ndpi_norm_value* scores = malloc(n_metrics * sizeof(ndpi_norm_value));
/* pktlen_s_to_c_max */
@@ -208,7 +206,6 @@ double Dos_hulk_score(struct ndpi_flow_info* flow){
}
double Dos_slow_score(struct ndpi_flow_info* flow){
double f = (double)flow->first_seen/1000.0, l = (double)flow->last_seen/1000.0;
int n_metrics = 6;
ndpi_norm_value* scores = malloc(n_metrics * sizeof(ndpi_norm_value));
/* pktlen_s_to_c_max */
@@ -260,7 +257,6 @@ double Dos_slow_score(struct ndpi_flow_info* flow){
}
double Ftp_patator_score(struct ndpi_flow_info* flow){
double f = (double)flow->first_seen/1000.0, l = (double)flow->last_seen/1000.0;
int n_metrics = 6;
ndpi_norm_value* scores = malloc(n_metrics * sizeof(ndpi_norm_value));
/* iat_flow_min */
@@ -364,7 +360,6 @@ double Hearthbleed_score(struct ndpi_flow_info* flow){
}
double Infiltration_score(struct ndpi_flow_info* flow){
double f = (double)flow->first_seen/1000.0, l = (double)flow->last_seen/1000.0;
int n_metrics = 6;
ndpi_norm_value* scores = malloc(n_metrics * sizeof(ndpi_norm_value));
/* pktlen_c_to_s_max */
@@ -416,7 +411,6 @@ double Infiltration_score(struct ndpi_flow_info* flow){
}
double Ssh_patator_score(struct ndpi_flow_info* flow){
double f = (double)flow->first_seen/1000.0, l = (double)flow->last_seen/1000.0;
int n_metrics = 6;
ndpi_norm_value* scores = malloc(n_metrics * sizeof(ndpi_norm_value));
/* fin */
+4
View File
@@ -218,6 +218,7 @@ FILE *trace = NULL;
*/
static void setupDetection(u_int16_t thread_id, pcap_t * pcap_handle);
#if 0
static void reduceBDbits(uint32_t *bd, unsigned int len) {
int mask = 0;
int shift = 0;
@@ -238,6 +239,7 @@ static void reduceBDbits(uint32_t *bd, unsigned int len) {
for(i = 0; i < len; i++)
bd[i] = bd[i] >> shift;
}
#endif
/**
* @brief Get flow byte distribution mean and variance
@@ -1530,12 +1532,14 @@ static int acceptable(u_int32_t num_pkts){
/* *********************************************** */
#if 0
static int receivers_sort(void *_a, void *_b) {
struct receiver *a = (struct receiver *)_a;
struct receiver *b = (struct receiver *)_b;
return(b->num_pkts - a->num_pkts);
}
#endif
/* *********************************************** */
+2 -2
View File
@@ -1216,7 +1216,7 @@ static struct ndpi_proto packet_processing(struct ndpi_workflow * workflow,
u_int8_t *payload;
u_int8_t src_to_dst_direction = 1;
u_int8_t begin_or_end_tcp = 0;
struct ndpi_proto nproto = { NDPI_PROTOCOL_UNKNOWN, NDPI_PROTOCOL_UNKNOWN };
struct ndpi_proto nproto = NDPI_PROTOCOL_NULL;
if(iph)
flow = get_ndpi_flow_info(workflow, IPVERSION, vlan_id,
@@ -1447,7 +1447,7 @@ struct ndpi_proto ndpi_workflow_process_packet(struct ndpi_workflow * workflow,
/** --- IPv6 header --- **/
struct ndpi_ipv6hdr *iph6;
struct ndpi_proto nproto = { NDPI_PROTOCOL_UNKNOWN, NDPI_PROTOCOL_UNKNOWN };
struct ndpi_proto nproto = NDPI_PROTOCOL_NULL;
ndpi_packet_tunnel tunnel_type = ndpi_no_tunnel;
/* lengths and offsets */
+1 -1
View File
@@ -966,7 +966,7 @@ typedef struct ndpi_proto {
ndpi_protocol_category_t category;
} ndpi_protocol;
#define NDPI_PROTOCOL_NULL { NDPI_PROTOCOL_UNKNOWN , NDPI_PROTOCOL_UNKNOWN }
#define NDPI_PROTOCOL_NULL { NDPI_PROTOCOL_UNKNOWN , NDPI_PROTOCOL_UNKNOWN , NDPI_PROTOCOL_CATEGORY_UNSPECIFIED }
#define NUM_CUSTOM_CATEGORIES 5
#define CUSTOM_CATEGORY_LABEL_LEN 32
+1 -1
View File
@@ -9137,7 +9137,7 @@ static ndpi_protocol_match host_match[] = {
{ "brasilbandalarga.com.br", NULL, "brasilbandalarga\\.com" TLD, "EAQ", NDPI_PROTOCOL_EAQ, NDPI_PROTOCOL_CATEGORY_NETWORK, NDPI_PROTOCOL_ACCEPTABLE },
{ ".eaqbr.com.br", NULL, "\\.eaqbr\\.com" TLD, "EAQ", NDPI_PROTOCOL_EAQ, NDPI_PROTOCOL_CATEGORY_NETWORK, NDPI_PROTOCOL_ACCEPTABLE },
{ NULL, NULL, NULL, 0 }
{ NULL, NULL, NULL, NULL, NDPI_PROTOCOL_UNKNOWN, NDPI_PROTOCOL_CATEGORY_UNSPECIFIED, NDPI_PROTOCOL_SAFE}
};
/* ******************************************************************** */
+5
View File
@@ -129,19 +129,24 @@ void ndpi_check_rx(struct ndpi_detection_module_struct *ndpi_struct,
header->flags == PLUS_2 || header->flags == REQ_ACK ||
header->flags == MORE_1)
goto security;
/* Fall-through */
case ACK:
if(header->flags == CLIENT_INIT_1 || header->flags == CLIENT_INIT_2 ||
header->flags == EMPTY)
goto security;
/* Fall-through */
case CHALLENGE:
if(header->flags == EMPTY || header->call_number == 0)
goto security;
/* Fall-through */
case RESPONSE:
if(header->flags == EMPTY || header->call_number == 0)
goto security;
/* Fall-through */
case ACKALL:
if(header->flags == EMPTY)
goto security;
/* Fall-through */
case BUSY:
goto security;
case ABORT:
+4 -2
View File
@@ -316,8 +316,10 @@ static void processCertificateElements(struct ndpi_detection_module_struct *ndpi
i += 2;
if((len > sizeof(dNSName)-1) || (len == 0 /* Looks something went wrong */))
break; /* String too long */
/* The check "len > sizeof(dNSName) - 1" will be always false. If we add it,
the compiler is smart enough to detect it and throws a warning */
if((len == 0 /* Looks something went wrong */))
break;
strncpy(dNSName, (const char*)&packet->payload[i], len);
dNSName[len] = '\0';