Compile everything with "-W -Wall -Wno-unused-parameter" flags (#1276)
Fix all the warnings. Getting rid of "-Wno-unused-parameter" is quite complex because some parameters usage depends on compilation variable (i.e. `--enable-debug-messages`). The "-Werror" flag has been added only in Travis builds to avoid breaking the builds to users using uncommon/untested OS/compiler/enviroment. Tested on: * x86_64; Ubuntu 20.04; gcc 7,8,9,10,11; clang 7,8,9,10,11,12 * x86_64; CentOS 7.7; gcc 4.8.5 (with "--disable-gcrypt" flag) * Raspberry 4; Debian 10.10; gcc 8.3.0
This commit is contained in:
@@ -687,7 +687,7 @@ extern "C" {
|
||||
*
|
||||
* @par ndpi_mod = the detection module
|
||||
*/
|
||||
void ndpi_dump_risks_score();
|
||||
void ndpi_dump_risks_score(void);
|
||||
|
||||
/**
|
||||
* Read a file and load the protocols
|
||||
|
||||
@@ -1512,12 +1512,14 @@ struct ndpi_flow_struct {
|
||||
struct ndpi_id_struct *dst;
|
||||
};
|
||||
|
||||
#define NDPI_PROTOCOL_DEFAULT_LEVEL 0
|
||||
|
||||
typedef struct {
|
||||
char *string_to_match, *proto_name;
|
||||
u_int16_t protocol_id;
|
||||
ndpi_protocol_category_t protocol_category;
|
||||
ndpi_protocol_breed_t protocol_breed;
|
||||
int level; /* 0 by default */
|
||||
int level; /* NDPI_PROTOCOL_DEFAULT_LEVEL (0) by default */
|
||||
} ndpi_protocol_match;
|
||||
|
||||
typedef struct {
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ prefix = @prefix@
|
||||
libdir = ${prefix}/lib
|
||||
includedir = ${prefix}/include/ndpi
|
||||
CC = @GNU_PREFIX@@CC@
|
||||
CFLAGS += -fPIC -DPIC -I../include -Ithird_party/include -DNDPI_LIB_COMPILATION -Wall @CFLAGS@ @CUSTOM_NDPI@
|
||||
CFLAGS += -fPIC -DPIC -I../include -Ithird_party/include -DNDPI_LIB_COMPILATION @CFLAGS@ @CUSTOM_NDPI@
|
||||
LDFLAGS = @LDFLAGS@ @ADDITIONAL_LIBS@ @LIBS@
|
||||
RANLIB = @GNU_PREFIX@ranlib
|
||||
|
||||
|
||||
@@ -189,7 +189,7 @@ https://github.com/corelight/community-id-spec/blob/bda913f617389df07cdaa23606e1
|
||||
*/
|
||||
static int ndpi_community_id_finalize_and_compute_hash(u_int8_t *comm_buf, u_int16_t off, u_int8_t l4_proto,
|
||||
u_int16_t src_port, u_int16_t dst_port,
|
||||
char *hash_buf, u_int8_t hash_buf_len) {
|
||||
char *hash_buf, size_t hash_buf_len) {
|
||||
u_int8_t pad = 0;
|
||||
uint32_t hash[5];
|
||||
char *community_id;
|
||||
|
||||
+529
-529
File diff suppressed because it is too large
Load Diff
+22
-21
@@ -723,7 +723,7 @@ static unsigned int imposible_bigrams_bitmap[(XGRAMS_C*XGRAMS_C+31)/32];
|
||||
static unsigned int trigrams_bitmap[(XGRAMS_C*XGRAMS_C*XGRAMS_C+31)/32];
|
||||
|
||||
|
||||
static void ndpi_xgrams_init(unsigned int *dst,size_t dn, const char **src,size_t sn,int l) {
|
||||
static void ndpi_xgrams_init(unsigned int *dst,size_t dn, const char **src,size_t sn, unsigned int l) {
|
||||
unsigned int i,j,c;
|
||||
for(i=0;i < sn && src[i]; i++) {
|
||||
for(j=0,c=0; j < l; j++) {
|
||||
@@ -810,7 +810,7 @@ int ndpi_set_detection_preferences(struct ndpi_detection_module_struct *ndpi_str
|
||||
static void ndpi_validate_protocol_initialization(struct ndpi_detection_module_struct *ndpi_str) {
|
||||
u_int i, val;
|
||||
|
||||
for(i = 0; i < (int) ndpi_str->ndpi_num_supported_protocols; i++) {
|
||||
for(i = 0; i < ndpi_str->ndpi_num_supported_protocols; i++) {
|
||||
if(ndpi_str->proto_defaults[i].protoName == NULL) {
|
||||
NDPI_LOG_ERR(ndpi_str,
|
||||
"[NDPI] INTERNAL ERROR missing protoName initialization for [protoId=%d]: recovering\n", i);
|
||||
@@ -2526,7 +2526,7 @@ void ndpi_finalize_automa(void *_automa) {
|
||||
static int ndpi_match_string_common(AC_AUTOMATA_t *automa, char *string_to_match,size_t string_len,
|
||||
u_int32_t *protocol_id, ndpi_protocol_category_t *category,
|
||||
ndpi_protocol_breed_t *breed) {
|
||||
AC_REP_t match = { NDPI_PROTOCOL_UNKNOWN, NDPI_PROTOCOL_CATEGORY_UNSPECIFIED, NDPI_PROTOCOL_UNRATED };
|
||||
AC_REP_t match = { NDPI_PROTOCOL_UNKNOWN, NDPI_PROTOCOL_CATEGORY_UNSPECIFIED, NDPI_PROTOCOL_UNRATED, 0, 0, 0, 0, 0 };
|
||||
AC_TEXT_t ac_input_text;
|
||||
int rc;
|
||||
|
||||
@@ -2592,7 +2592,6 @@ int ndpi_match_string_protocol_id(void *automa, char *string_to_match,
|
||||
|
||||
int ndpi_match_string_value(void *automa, char *string_to_match,
|
||||
u_int match_len, u_int32_t *num) {
|
||||
|
||||
int rc = ndpi_match_string_common((AC_AUTOMATA_t *)automa, string_to_match,
|
||||
match_len, num, NULL, NULL);
|
||||
if(rc < 0) return rc;
|
||||
@@ -3348,7 +3347,7 @@ int ndpi_load_malicious_sha1_file(struct ndpi_detection_module_struct *ndpi_str,
|
||||
char buffer[128];
|
||||
char *first_comma, *second_comma, *str;
|
||||
FILE *fd;
|
||||
size_t len;
|
||||
size_t i, len;
|
||||
int num = 0;
|
||||
|
||||
if (ndpi_str->malicious_sha1_automa.ac_automa == NULL)
|
||||
@@ -3384,7 +3383,7 @@ int ndpi_load_malicious_sha1_file(struct ndpi_detection_module_struct *ndpi_str,
|
||||
continue;
|
||||
second_comma[0] = '\0';
|
||||
|
||||
for (size_t i = 0; i < 40; ++i)
|
||||
for (i = 0; i < 40; ++i)
|
||||
first_comma[i] = toupper(first_comma[i]);
|
||||
|
||||
str = ndpi_strdup(first_comma);
|
||||
@@ -4630,6 +4629,7 @@ static u_int32_t check_ndpi_detection_func(struct ndpi_detection_module_struct *
|
||||
u_int16_t proto_index = ndpi_str->proto_defaults[flow->guessed_protocol_id].protoIdx;
|
||||
u_int16_t proto_id = ndpi_str->proto_defaults[flow->guessed_protocol_id].protoId;
|
||||
NDPI_PROTOCOL_BITMASK detection_bitmask;
|
||||
u_int32_t a;
|
||||
|
||||
NDPI_SAVE_AS_BITMASK(detection_bitmask, flow->packet.detected_protocol_stack[0]);
|
||||
|
||||
@@ -4654,7 +4654,7 @@ static u_int32_t check_ndpi_detection_func(struct ndpi_detection_module_struct *
|
||||
|
||||
if (flow->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN)
|
||||
{
|
||||
for (u_int32_t a = 0; a < callback_buffer_size; a++) {
|
||||
for (a = 0; a < callback_buffer_size; a++) {
|
||||
if ((func != callback_buffer[a].func) &&
|
||||
(callback_buffer[a].ndpi_selection_bitmask & ndpi_selection_packet) ==
|
||||
callback_buffer[a].ndpi_selection_bitmask &&
|
||||
@@ -4675,7 +4675,7 @@ static u_int32_t check_ndpi_detection_func(struct ndpi_detection_module_struct *
|
||||
}
|
||||
|
||||
/* Check for subprotocols. */
|
||||
for (u_int32_t a = 0; a < ndpi_str->proto_defaults[flow->detected_protocol_stack[0]].subprotocol_count; a++)
|
||||
for (a = 0; a < ndpi_str->proto_defaults[flow->detected_protocol_stack[0]].subprotocol_count; a++)
|
||||
{
|
||||
u_int16_t subproto_id = ndpi_str->proto_defaults[flow->detected_protocol_stack[0]].subprotocols[a];
|
||||
if (subproto_id == (uint16_t)NDPI_PROTOCOL_MATCHED_BY_CONTENT)
|
||||
@@ -5493,7 +5493,7 @@ ndpi_protocol ndpi_detection_process_packet(struct ndpi_detection_module_struct
|
||||
a = NDPI_PROTOCOL_UNKNOWN;
|
||||
|
||||
if(a != NDPI_PROTOCOL_UNKNOWN) {
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
for(i = 0; i < sizeof(flow->host_server_name); i++) {
|
||||
if(flow->host_server_name[i] != '\0')
|
||||
@@ -5812,7 +5812,7 @@ void ndpi_parse_packet_line_info(struct ndpi_detection_module_struct *ndpi_str,
|
||||
diff = packet->payload_packet_len - a1;
|
||||
|
||||
if(diff > 0) {
|
||||
diff = ndpi_min(diff, sizeof(flow->initial_binary_bytes));
|
||||
diff = ndpi_min((unsigned int)diff, sizeof(flow->initial_binary_bytes));
|
||||
memcpy(&flow->initial_binary_bytes, &packet->payload[a1], diff);
|
||||
flow->initial_binary_bytes_len = diff;
|
||||
}
|
||||
@@ -6779,7 +6779,7 @@ void ndpi_dump_risks_score() {
|
||||
|
||||
for(i = 1; i < NDPI_MAX_RISK; i++) {
|
||||
ndpi_risk_enum r = (ndpi_risk_enum)i;
|
||||
ndpi_risk risk = 2 << (r-1);
|
||||
ndpi_risk risk = (uint64_t)2 << (r-1);
|
||||
ndpi_risk_info* info = ndpi_risk2severity(r);
|
||||
ndpi_risk_severity s =info->severity;
|
||||
u_int16_t client_score, server_score;
|
||||
@@ -6866,7 +6866,7 @@ int ndpi_match_string_subprotocol(struct ndpi_detection_module_struct *ndpi_str,
|
||||
rc = ndpi_match_string_common(((AC_AUTOMATA_t *) automa->ac_automa),
|
||||
string_to_match,string_to_match_len, &ret_match->protocol_id,
|
||||
&ret_match->protocol_category, &ret_match->protocol_breed);
|
||||
return rc < 0 ? rc : ret_match->protocol_id;
|
||||
return rc < 0 ? rc : (int)ret_match->protocol_id;
|
||||
}
|
||||
|
||||
/* **************************************** */
|
||||
@@ -7023,7 +7023,7 @@ u_int16_t ndpi_match_content_subprotocol(struct ndpi_detection_module_struct *nd
|
||||
|
||||
/* ****************************************************** */
|
||||
|
||||
static inline int ndpi_match_xgram(unsigned int *map,int l,const char *str) {
|
||||
static inline int ndpi_match_xgram(unsigned int *map,unsigned int l,const char *str) {
|
||||
unsigned int i,c;
|
||||
for(i=0,c=0; *str && i < l; i++) {
|
||||
unsigned char a = (unsigned char)(*str++);
|
||||
@@ -7066,7 +7066,7 @@ char *ndpi_revision() {
|
||||
/* ****************************************************** */
|
||||
|
||||
int NDPI_BITMASK_COMPARE(NDPI_PROTOCOL_BITMASK a, NDPI_PROTOCOL_BITMASK b) {
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
for(i = 0; i < NDPI_NUM_FDS_BITS; i++) {
|
||||
if(a.fds_bits[i] & b.fds_bits[i])
|
||||
@@ -7078,7 +7078,7 @@ int NDPI_BITMASK_COMPARE(NDPI_PROTOCOL_BITMASK a, NDPI_PROTOCOL_BITMASK b) {
|
||||
|
||||
#ifdef CODE_UNUSED
|
||||
int NDPI_BITMASK_IS_EMPTY(NDPI_PROTOCOL_BITMASK a) {
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
for(i = 0; i < NDPI_NUM_FDS_BITS; i++)
|
||||
if(a.fds_bits[i] != 0)
|
||||
@@ -7088,7 +7088,7 @@ int NDPI_BITMASK_IS_EMPTY(NDPI_PROTOCOL_BITMASK a) {
|
||||
}
|
||||
|
||||
void NDPI_DUMP_BITMASK(NDPI_PROTOCOL_BITMASK a) {
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
for(i = 0; i < NDPI_NUM_FDS_BITS; i++)
|
||||
printf("[%d=%u]", i, a.fds_bits[i]);
|
||||
@@ -7508,11 +7508,11 @@ int ndpi_check_dga_name(struct ndpi_detection_module_struct *ndpi_str,
|
||||
len = strlen(name);
|
||||
|
||||
if(len >= 5) {
|
||||
int i, j, num_found = 0, num_impossible = 0, num_bigram_checks = 0,
|
||||
int num_found = 0, num_impossible = 0, num_bigram_checks = 0,
|
||||
num_trigram_found = 0, num_trigram_checked = 0, num_dash = 0,
|
||||
num_digits = 0, num_vowels = 0, num_trigram_vowels = 0, num_words = 0, skip_next_bigram = 0;
|
||||
char tmp[128], *word, *tok_tmp;
|
||||
u_int max_tmp_len = sizeof(tmp)-1;
|
||||
u_int i, j, max_tmp_len = sizeof(tmp)-1;
|
||||
|
||||
len = snprintf(tmp, max_tmp_len, "%s", name);
|
||||
if(len < 0) {
|
||||
@@ -7522,9 +7522,9 @@ int ndpi_check_dga_name(struct ndpi_detection_module_struct *ndpi_str,
|
||||
|
||||
return(0);
|
||||
} else
|
||||
tmp[len < max_tmp_len ? len : max_tmp_len] = '\0';
|
||||
tmp[(u_int)len < max_tmp_len ? (u_int)len : max_tmp_len] = '\0';
|
||||
|
||||
for(i=0, j=0; (i<len) && (j<max_tmp_len); i++) {
|
||||
for(i=0, j=0; (i<(u_int)len) && (j<max_tmp_len); i++) {
|
||||
tmp[j] = tolower(name[i]);
|
||||
|
||||
if(tmp[j] == '.') {
|
||||
@@ -7546,7 +7546,7 @@ int ndpi_check_dga_name(struct ndpi_detection_module_struct *ndpi_str,
|
||||
if(isdigit(tmp[j])) {
|
||||
num_digits++;
|
||||
|
||||
if(((j+2)<len) && isdigit(tmp[j+1]) && (tmp[j+2] == '.')) {
|
||||
if(((j+2)<(u_int)len) && isdigit(tmp[j+1]) && (tmp[j+2] == '.')) {
|
||||
/* Check if there are too many digits */
|
||||
if(num_digits < 4)
|
||||
return(0); /* Double digits */
|
||||
@@ -7646,6 +7646,7 @@ int ndpi_check_dga_name(struct ndpi_detection_module_struct *ndpi_str,
|
||||
*/
|
||||
if(word[i+1] == '-')
|
||||
return(0); /* Double dash */
|
||||
continue;
|
||||
|
||||
case '_':
|
||||
case ':':
|
||||
|
||||
@@ -71,7 +71,7 @@ u_int64_t ndpi_ntohll(u_int64_t v) {
|
||||
/* ********************************** */
|
||||
|
||||
static int ndpi_is_number(const char *str, u_int32_t str_len) {
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
for(i = 0; i < str_len; i++)
|
||||
if(!isdigit(str[i])) return(0);
|
||||
|
||||
@@ -1048,7 +1048,7 @@ u_char* ndpi_base64_decode(const u_char *src, size_t len, size_t *out_len) {
|
||||
char* ndpi_base64_encode(unsigned char const* bytes_to_encode, size_t in_len) {
|
||||
size_t len = 0, ret_size;
|
||||
char *ret;
|
||||
int i = 0;
|
||||
int j, i = 0;
|
||||
unsigned char char_array_3[3];
|
||||
unsigned char char_array_4[4];
|
||||
|
||||
@@ -1072,7 +1072,7 @@ char* ndpi_base64_encode(unsigned char const* bytes_to_encode, size_t in_len) {
|
||||
}
|
||||
|
||||
if(i) {
|
||||
for(int j = i; j < 3; j++)
|
||||
for(j = i; j < 3; j++)
|
||||
char_array_3[j] = '\0';
|
||||
|
||||
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
|
||||
@@ -1080,7 +1080,7 @@ char* ndpi_base64_encode(unsigned char const* bytes_to_encode, size_t in_len) {
|
||||
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
|
||||
char_array_4[3] = char_array_3[2] & 0x3f;
|
||||
|
||||
for(int j = 0; (j < i + 1); j++)
|
||||
for(j = 0; (j < i + 1); j++)
|
||||
ret[len++] = base64_table[char_array_4[j]];
|
||||
|
||||
while((i++ < 3))
|
||||
|
||||
@@ -419,7 +419,7 @@ const u_int8_t *bt_decode(const u_int8_t *b, size_t *l, int *ret, bt_parse_data_
|
||||
if(c != ':') goto bad_data;
|
||||
break;
|
||||
}
|
||||
if(d > *l) goto bad_data;
|
||||
if((size_t)d > *l) goto bad_data;
|
||||
cbd->t = 2;
|
||||
cbd->v.s.s = b;
|
||||
cbd->v.s.l = d;
|
||||
|
||||
@@ -51,7 +51,7 @@ static u_int32_t skip_unknown_headers(const u_int8_t * payload, u_int32_t payloa
|
||||
}
|
||||
|
||||
static u_int16_t parse_binf_message(struct ndpi_detection_module_struct
|
||||
*ndpi_struct, const u_int8_t * payload, int payload_len)
|
||||
*ndpi_struct, const u_int8_t * payload, uint32_t payload_len)
|
||||
{
|
||||
u_int32_t i = 4;
|
||||
u_int16_t bytes_read = 0;
|
||||
|
||||
@@ -238,12 +238,13 @@ static ndpi_protocol_category_t ndpi_http_check_content(struct ndpi_detection_mo
|
||||
|
||||
if(packet->content_disposition_line.len > attachment_len) {
|
||||
u_int8_t filename_len = packet->content_disposition_line.len - attachment_len;
|
||||
int i;
|
||||
|
||||
if(filename_len > ATTACHMENT_LEN) {
|
||||
attachment_len += filename_len-ATTACHMENT_LEN-1;
|
||||
|
||||
if((attachment_len+ATTACHMENT_LEN) <= packet->content_disposition_line.len) {
|
||||
for(int i = 0; binary_file_ext[i] != NULL; i++) {
|
||||
for(i = 0; binary_file_ext[i] != NULL; i++) {
|
||||
/* Use memcmp in case content-disposition contains binary data */
|
||||
if(memcmp(&packet->content_disposition_line.ptr[attachment_len],
|
||||
binary_file_ext[i], ATTACHMENT_LEN) == 0) {
|
||||
@@ -715,7 +716,7 @@ static const char *http_fs = "CDGHOPR";
|
||||
static u_int16_t http_request_url_offset(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
NDPI_LOG_DBG2(ndpi_struct, "====>>>> HTTP: %c%c%c%c [len: %u]\n",
|
||||
packet->payload_packet_len > 0 ? non_ctrl(packet->payload[0]) : '.',
|
||||
|
||||
@@ -302,7 +302,7 @@ void ndpi_search_kerberos(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
#endif
|
||||
|
||||
if(body_offset < packet->payload_packet_len) {
|
||||
u_int name_offset, padding_offset = body_offset + 4;
|
||||
u_int16_t name_offset, padding_offset = body_offset + 4;
|
||||
|
||||
name_offset = padding_offset;
|
||||
for(i=0; i<14; i++) if(packet->payload[name_offset] != 0x1b) name_offset++; /* ASN.1 */
|
||||
|
||||
@@ -88,7 +88,8 @@ void ndpi_search_mail_smtp_tcp(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
|
||||
if(flow->host_server_name[0] == '\0') {
|
||||
if(packet->line[a].len > 4) {
|
||||
int i, len;
|
||||
int i;
|
||||
unsigned int len;
|
||||
|
||||
if(packet->line[a].ptr[4] != '(') {
|
||||
for(i=5; (i<packet->line[a].len-1) && (packet->line[a].ptr[i] != ' '); i++)
|
||||
|
||||
@@ -172,7 +172,7 @@ void ndpi_search_netflow(struct ndpi_detection_module_struct *ndpi_struct, struc
|
||||
now = now_tv.tv_sec;
|
||||
|
||||
if(((version == 1) && (when == 0))
|
||||
|| ((when >= 946684800 /* 1/1/2000 */) && (when <= now))) {
|
||||
|| ((when >= 946684800 /* 1/1/2000 */) && (when <= (u_int32_t)now))) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found netflow\n");
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_NETFLOW, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
|
||||
@@ -79,19 +79,19 @@ void ndpi_search_postgres_tcp(struct ndpi_detection_module_struct
|
||||
if (flow->l4.tcp.postgres_stage == 4 - packet->packet_direction)
|
||||
if (packet->payload_packet_len > 8 &&
|
||||
ntohl(get_u_int32_t(packet->payload, 5)) < 10 &&
|
||||
ntohl(get_u_int32_t(packet->payload, 1)) == packet->payload_packet_len - 1 && packet->payload[0] == 0x52) {
|
||||
ntohl(get_u_int32_t(packet->payload, 1)) == (uint32_t)packet->payload_packet_len - 1 && packet->payload[0] == 0x52) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "PostgreSQL detected, no SSL\n");
|
||||
ndpi_int_postgres_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
if (flow->l4.tcp.postgres_stage == 6
|
||||
&& ntohl(get_u_int32_t(packet->payload, 1)) == packet->payload_packet_len - 1 && packet->payload[0] == 'p') {
|
||||
&& ntohl(get_u_int32_t(packet->payload, 1)) == (uint32_t)packet->payload_packet_len - 1 && packet->payload[0] == 'p') {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found postgres asymmetrically\n");
|
||||
ndpi_int_postgres_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
if (flow->l4.tcp.postgres_stage == 5 && packet->payload[0] == 'R') {
|
||||
if (ntohl(get_u_int32_t(packet->payload, 1)) == packet->payload_packet_len - 1) {
|
||||
if (ntohl(get_u_int32_t(packet->payload, 1)) == (uint32_t)packet->payload_packet_len - 1) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found postgres asymmetrically\n");
|
||||
ndpi_int_postgres_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
|
||||
@@ -1010,7 +1010,7 @@ static int __reassemble(struct ndpi_flow_struct *flow, const u_int8_t *frag,
|
||||
uint64_t frag_len, uint64_t frag_offset,
|
||||
const u_int8_t **buf, u_int64_t *buf_len)
|
||||
{
|
||||
const int max_quic_reasm_buffer_len = 4096; /* Let's say a couple of full-MTU packets... */
|
||||
const uint64_t max_quic_reasm_buffer_len = 4096; /* Let's say a couple of full-MTU packets... */
|
||||
|
||||
/* TODO: at the moment, this function is only a little more than a stub.
|
||||
We should reassemble the fragments, but nDPI lacks any proper generic
|
||||
@@ -1580,7 +1580,7 @@ static void ndpi_search_quic(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int8_t *clear_payload;
|
||||
uint32_t clear_payload_len;
|
||||
uint32_t clear_payload_len = 0;
|
||||
const u_int8_t *crypto_data;
|
||||
uint64_t crypto_data_len;
|
||||
int is_quic;
|
||||
|
||||
+26
-26
@@ -48,19 +48,19 @@ struct ndpi_rx_header {
|
||||
} PACK_OFF;
|
||||
|
||||
/* Type values */
|
||||
#define DATA 1
|
||||
#define ACK 2
|
||||
#define BUSY 3
|
||||
#define ABORT 4
|
||||
#define ACKALL 5
|
||||
#define CHALLENGE 6
|
||||
#define RESPONSE 7
|
||||
#define DEBUG 8
|
||||
#define PARAM_1 9
|
||||
#define PARAM_2 10
|
||||
#define PARAM_3 11
|
||||
#define PARAMS_4 12
|
||||
#define VERS 13
|
||||
#define RX_DATA 1
|
||||
#define RX_ACK 2
|
||||
#define RX_BUSY 3
|
||||
#define RX_ABORT 4
|
||||
#define RX_ACKALL 5
|
||||
#define RX_CHALLENGE 6
|
||||
#define RX_RESPONSE 7
|
||||
#define RX_DEBUG 8
|
||||
#define RX_PARAM_1 9
|
||||
#define RX_PARAM_2 10
|
||||
#define RX_PARAM_3 11
|
||||
#define RX_PARAMS_4 12
|
||||
#define RX_VERS 13
|
||||
|
||||
/* Flags values */
|
||||
#define EMPTY 0
|
||||
@@ -108,7 +108,7 @@ void ndpi_check_rx(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
**/
|
||||
|
||||
/* TYPE field */
|
||||
if((header->type < DATA) || (header->type > VERS)) {
|
||||
if((header->type < RX_DATA) || (header->type > RX_VERS)) {
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
@@ -123,43 +123,43 @@ void ndpi_check_rx(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
/* TYPE and FLAGS combo */
|
||||
switch(header->type)
|
||||
{
|
||||
case DATA:
|
||||
case RX_DATA:
|
||||
if(header->flags == LAST_PKT || header->flags == EMPTY ||
|
||||
header->flags == PLUS_0 || header->flags == PLUS_1 ||
|
||||
header->flags == PLUS_2 || header->flags == REQ_ACK ||
|
||||
header->flags == MORE_1)
|
||||
goto security;
|
||||
/* Fall-through */
|
||||
case ACK:
|
||||
case RX_ACK:
|
||||
if(header->flags == CLIENT_INIT_1 || header->flags == CLIENT_INIT_2 ||
|
||||
header->flags == EMPTY)
|
||||
goto security;
|
||||
/* Fall-through */
|
||||
case CHALLENGE:
|
||||
case RX_CHALLENGE:
|
||||
if(header->flags == EMPTY || header->call_number == 0)
|
||||
goto security;
|
||||
/* Fall-through */
|
||||
case RESPONSE:
|
||||
case RX_RESPONSE:
|
||||
if(header->flags == EMPTY || header->call_number == 0)
|
||||
goto security;
|
||||
/* Fall-through */
|
||||
case ACKALL:
|
||||
case RX_ACKALL:
|
||||
if(header->flags == EMPTY)
|
||||
goto security;
|
||||
/* Fall-through */
|
||||
case BUSY:
|
||||
case RX_BUSY:
|
||||
goto security;
|
||||
case ABORT:
|
||||
case RX_ABORT:
|
||||
goto security;
|
||||
case DEBUG:
|
||||
case RX_DEBUG:
|
||||
goto security;
|
||||
case PARAM_1:
|
||||
case RX_PARAM_1:
|
||||
goto security;
|
||||
case PARAM_2:
|
||||
case RX_PARAM_2:
|
||||
goto security;
|
||||
case PARAM_3:
|
||||
case RX_PARAM_3:
|
||||
goto security;
|
||||
case VERS:
|
||||
case RX_VERS:
|
||||
goto security;
|
||||
default:
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
|
||||
@@ -30,7 +30,7 @@ static int is_port(u_int16_t a, u_int16_t b, u_int16_t c) {
|
||||
static int ndpi_check_skype_udp_again(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
u_int32_t payload_len = packet->payload_packet_len;
|
||||
|
||||
int i;
|
||||
const uint8_t id_flags_iv_crc_len = 11;
|
||||
const uint8_t crc_len = sizeof(flow->l4.udp.skype_crc);
|
||||
const uint8_t crc_offset = id_flags_iv_crc_len - crc_len;
|
||||
@@ -48,7 +48,7 @@ static int ndpi_check_skype_udp_again(struct ndpi_detection_module_struct *ndpi_
|
||||
u_int8_t detected = 1;
|
||||
|
||||
/* Check if both packets have the same CRC */
|
||||
for (int i = 0; i < crc_len && detected; i++) {
|
||||
for (i = 0; i < crc_len && detected; i++) {
|
||||
if (packet->payload[crc_offset + i] != flow->l4.udp.skype_crc[i])
|
||||
detected = 0;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ void ndpi_search_smb_tcp(struct ndpi_detection_module_struct *ndpi_struct, struc
|
||||
|
||||
if(((packet->tcp->dest == fourfourfive) || (packet->tcp->source == fourfourfive))
|
||||
&& packet->payload_packet_len > (32 + 4 + 4)
|
||||
&& (packet->payload_packet_len - 4) == ntohl(get_u_int32_t(packet->payload, 0))
|
||||
&& ((uint32_t)packet->payload_packet_len - 4) == ntohl(get_u_int32_t(packet->payload, 0))
|
||||
) {
|
||||
u_int8_t smbv1[] = { 0xff, 0x53, 0x4d, 0x42 };
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ void ndpi_search_smpp_tcp(struct ndpi_detection_module_struct* ndpi_struct,
|
||||
u_int32_t tmp_pdu_l = 0;
|
||||
u_int16_t pdu_c = 1;
|
||||
// loop PDUs (check if lengths are valid)
|
||||
while(total_pdu_l < (packet->payload_packet_len-4)) {
|
||||
while(total_pdu_l < ((uint32_t)packet->payload_packet_len-4)) {
|
||||
// get next PDU length
|
||||
tmp_pdu_l = ntohl(get_u_int32_t(packet->payload, total_pdu_l));
|
||||
// if zero or overflowing , return, will try the next TCP segment
|
||||
|
||||
@@ -112,7 +112,7 @@ void ndpi_search_soulseek_tcp(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
if(packet->payload_packet_len >= 12 && packet->payload_packet_len < 300 && get_l32(packet->payload, 4) == 1) {
|
||||
while (index + 4 < packet->payload_packet_len &&
|
||||
!get_u_int16_t(packet->payload, index + 2)
|
||||
&& (index + get_l32(packet->payload, index)) < packet->payload_packet_len - 4) {
|
||||
&& (index + get_l32(packet->payload, index)) < (u_int32_t)packet->payload_packet_len - 4) {
|
||||
if(get_l32(packet->payload, index) < 8) /*Minimum soulseek login msg is 8B */
|
||||
break;
|
||||
|
||||
@@ -125,7 +125,7 @@ void ndpi_search_soulseek_tcp(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
} /* while */
|
||||
|
||||
if((packet->payload_packet_len >= (index+4))
|
||||
&& (index + get_l32(packet->payload, index)) == (packet->payload_packet_len - 4)
|
||||
&& (index + get_l32(packet->payload, index)) == (u_int32_t)packet->payload_packet_len -4
|
||||
&& (get_u_int16_t(packet->payload, 10) != 0)) {
|
||||
/* This structure seems to be soulseek proto */
|
||||
index = get_l32(packet->payload, 8) + 12; // end of "user name"
|
||||
@@ -150,7 +150,7 @@ void ndpi_search_soulseek_tcp(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
}
|
||||
if (packet->payload_packet_len > 8
|
||||
&& (packet->payload_packet_len < 200)
|
||||
&& get_l32(packet->payload, 0) == (packet->payload_packet_len - 4)) {
|
||||
&& get_l32(packet->payload, 0) == (u_int32_t)packet->payload_packet_len -4) {
|
||||
//Server Messages:
|
||||
const u_int32_t msgcode = get_l32(packet->payload, 4);
|
||||
|
||||
@@ -177,7 +177,7 @@ void ndpi_search_soulseek_tcp(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
}
|
||||
}
|
||||
//Peer Messages : Peer Init Message Detection
|
||||
if(get_l32(packet->payload, 0) == packet->payload_packet_len - 4) {
|
||||
if(get_l32(packet->payload, 0) == (u_int32_t)packet->payload_packet_len - 4) {
|
||||
const u_int32_t typelen = get_l32(packet->payload, packet->payload_packet_len - 9);
|
||||
const u_int8_t type = packet->payload[packet->payload_packet_len - 5];
|
||||
const u_int32_t namelen = get_l32(packet->payload, 5);
|
||||
@@ -204,7 +204,7 @@ void ndpi_search_soulseek_tcp(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
&& !get_u_int16_t(packet->payload, 2)) {
|
||||
const u_int32_t usrlen = get_l32(packet->payload, 5);
|
||||
|
||||
if(usrlen <= packet->payload_packet_len - (4 + 1 + 4 + 4 + 1 + 4)) {
|
||||
if(usrlen <= (u_int32_t)packet->payload_packet_len - (4 + 1 + 4 + 4 + 1 + 4)) {
|
||||
const u_int32_t typelen = get_l32(packet->payload, 4 + 1 + 4 + usrlen);
|
||||
const u_int8_t type = packet->payload[4 + 1 + 4 + usrlen + 4];
|
||||
if(typelen == 1 && (type == 'F' || type == 'P' || type == 'D')) {
|
||||
@@ -223,7 +223,7 @@ void ndpi_search_soulseek_tcp(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
SOULSEEK_DETECT;
|
||||
return;
|
||||
}
|
||||
if(get_l32(packet->payload, 0) == packet->payload_packet_len - 4) {
|
||||
if(get_l32(packet->payload, 0) == (u_int32_t)packet->payload_packet_len - 4) {
|
||||
const u_int32_t msgcode = get_l32(packet->payload, 4);
|
||||
if(msgcode == 0x03 && packet->payload_packet_len >= 12) //Server Message : Get Peer Address
|
||||
{
|
||||
|
||||
@@ -89,12 +89,12 @@ static void ndpi_check_spotify(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
|
||||
//printf("%08X - %08X\n", ntohl(packet->iph->saddr), ntohl(packet->iph->daddr));
|
||||
|
||||
long src_addr = ntohl(packet->iph->saddr);
|
||||
long dst_addr = ntohl(packet->iph->daddr);
|
||||
long src_addr_masked_22 = src_addr & 0xFFFFFC00; // */22
|
||||
long dst_addr_masked_22 = dst_addr & 0xFFFFFC00; // */22
|
||||
long src_addr_masked_24 = src_addr & 0xFFFFFF00; // */24
|
||||
long dst_addr_masked_24 = dst_addr & 0xFFFFFF00; // */24
|
||||
unsigned long src_addr = ntohl(packet->iph->saddr);
|
||||
unsigned long dst_addr = ntohl(packet->iph->daddr);
|
||||
unsigned long src_addr_masked_22 = src_addr & 0xFFFFFC00; // */22
|
||||
unsigned long dst_addr_masked_22 = dst_addr & 0xFFFFFC00; // */22
|
||||
unsigned long src_addr_masked_24 = src_addr & 0xFFFFFF00; // */24
|
||||
unsigned long dst_addr_masked_24 = dst_addr & 0xFFFFFF00; // */24
|
||||
|
||||
if( src_addr_masked_22 == 0x4E1F0800 /* 78.31.8.0 */
|
||||
|| dst_addr_masked_22 == 0x4E1F0800 /* 78.31.8.0 */
|
||||
|
||||
@@ -75,7 +75,7 @@ static void ndpi_check_tinc(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
case 0:
|
||||
case 1:
|
||||
if(payload_len > 6 && memcmp(packet_payload, "0 ", 2) == 0 && packet_payload[2] != ' ') {
|
||||
u_int16_t i = 3;
|
||||
u_int32_t i = 3;
|
||||
while(i < payload_len && packet_payload[i++] != ' ');
|
||||
if(i+3 == payload_len && memcmp((packet_payload+i), "17\n", 3) == 0) {
|
||||
flow->tinc_state++;
|
||||
|
||||
+11
-9
@@ -222,7 +222,7 @@ void ndpi_search_tls_tcp_memory(struct ndpi_detection_module_struct *ndpi_struct
|
||||
|
||||
/* **************************************** */
|
||||
|
||||
static void cleanupServerName(char *buffer, int buffer_len) {
|
||||
static void cleanupServerName(char *buffer, u_int buffer_len) {
|
||||
u_int i;
|
||||
|
||||
/* Now all lowecase */
|
||||
@@ -318,7 +318,7 @@ static void processCertificateElements(struct ndpi_detection_module_struct *ndpi
|
||||
struct ndpi_flow_struct *flow,
|
||||
u_int16_t p_offset, u_int16_t certificate_len) {
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
u_int num_found = 0, i;
|
||||
u_int16_t num_found = 0, i;
|
||||
char buffer[64] = { '\0' }, rdnSeqBuf[2048] = { '\0' };
|
||||
u_int rdn_len = 0;
|
||||
|
||||
@@ -690,7 +690,7 @@ int processCertificate(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
|
||||
#ifdef DEBUG_CERTIFICATE_HASH
|
||||
{
|
||||
int i;
|
||||
u_int32_t i;
|
||||
|
||||
for(i=0;i<certificate_len;i++)
|
||||
printf("%02X ", packet->payload[certificates_offset+i]);
|
||||
@@ -711,7 +711,8 @@ int processCertificate(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
const size_t sha1_siz = sizeof(flow->protos.tls_quic_stun.tls_quic.sha1_certificate_fingerprint);
|
||||
char sha1_str[20 /* sha1_siz */ * 2 + 1];
|
||||
static const char hexalnum[] = "0123456789ABCDEF";
|
||||
for (size_t i = 0; i < sha1_siz; ++i) {
|
||||
size_t i;
|
||||
for (i = 0; i < sha1_siz; ++i) {
|
||||
u_int8_t lower = (sha1[i] & 0x0F);
|
||||
u_int8_t upper = (sha1[i] & 0xF0) >> 4;
|
||||
sha1_str[i*2] = hexalnum[upper];
|
||||
@@ -1097,7 +1098,7 @@ static void tlsCheckUncommonALPN(struct ndpi_detection_module_struct *ndpi_struc
|
||||
|
||||
if(!is_a_common_alpn(ndpi_struct, alpn_start, alpn_len)) {
|
||||
#ifdef DEBUG_TLS
|
||||
printf("TLS uncommon ALPN found: %.*s\n", alpn_len, alpn);
|
||||
printf("TLS uncommon ALPN found: %.*s\n", (int)alpn_len, alpn);
|
||||
#endif
|
||||
ndpi_set_risk(ndpi_struct, flow, NDPI_TLS_UNCOMMON_ALPN);
|
||||
break;
|
||||
@@ -1348,7 +1349,7 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
printf("Server TLS [ALPN: %u]\n", alpn_len);
|
||||
#endif
|
||||
|
||||
if((alpn_str_len+alpn_len+1) < (sizeof(alpn_str)-1)) {
|
||||
if(((uint32_t)alpn_str_len+alpn_len+1) < (sizeof(alpn_str)-1)) {
|
||||
if(alpn_str_len > 0) {
|
||||
alpn_str[alpn_str_len] = ',';
|
||||
alpn_str_len++;
|
||||
@@ -1823,7 +1824,8 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
continue;
|
||||
} else {
|
||||
/* Check for other duplications */
|
||||
u_int j, all_ok = 1;
|
||||
u_int all_ok = 1;
|
||||
int j;
|
||||
|
||||
for(j=0; j<tot_signature_algorithms_len; j+=2) {
|
||||
if(j != i) {
|
||||
@@ -1934,7 +1936,7 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
printf("Client TLS [ALPN: %u]\n", alpn_len);
|
||||
#endif
|
||||
|
||||
if((alpn_str_len+alpn_len+1) < (sizeof(alpn_str)-1)) {
|
||||
if(((uint32_t)alpn_str_len+alpn_len+1) < (sizeof(alpn_str)-1)) {
|
||||
if(alpn_str_len > 0) {
|
||||
alpn_str[alpn_str_len] = ',';
|
||||
alpn_str_len++;
|
||||
@@ -1968,7 +1970,7 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
u_int16_t s_offset = offset+extension_offset;
|
||||
u_int8_t version_len = packet->payload[s_offset];
|
||||
char version_str[256];
|
||||
u_int8_t version_str_len = 0;
|
||||
size_t version_str_len = 0;
|
||||
version_str[0] = 0;
|
||||
#ifdef DEBUG_TLS
|
||||
printf("Client TLS [TLS version len: %u]\n", version_len);
|
||||
|
||||
@@ -55,7 +55,8 @@ void ndpi_search_ubntac2(struct ndpi_detection_module_struct *ndpi_struct, struc
|
||||
|
||||
if(found < packet->payload_packet_len) {
|
||||
char version[256];
|
||||
int i, j, len;
|
||||
int len;
|
||||
u_int i, j;
|
||||
|
||||
for(i=found, j=0; (i < packet->payload_packet_len)
|
||||
&& (i < (sizeof(version)-1))
|
||||
|
||||
+1
-1
@@ -383,7 +383,7 @@ AC_ERROR_t ac_automata_finalize (AC_AUTOMATA_t * thiz) {
|
||||
int ac_automata_exact_match(AC_PATTERNS_t *mp,int pos, AC_TEXT_t *txt) {
|
||||
AC_PATTERN_t *patterns = mp->patterns;
|
||||
AC_PATTERN_t **matched = txt->match.matched;
|
||||
int i;
|
||||
unsigned int i;
|
||||
int match_map = 0;
|
||||
for(i=0; i < mp->num && i < ((sizeof(int)*8)-1); i++,patterns++) {
|
||||
do {
|
||||
|
||||
Vendored
+1
-1
@@ -300,7 +300,7 @@ cache_result cache_remove(cache_t cache, void *item, uint32_t item_size) {
|
||||
}
|
||||
|
||||
void cache_free(cache_t cache) {
|
||||
int i;
|
||||
uint32_t i;
|
||||
if(!cache) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user