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:
Ivan Nardi
2021-08-20 18:11:13 +02:00
committed by GitHub
parent 55eec29c08
commit 8fdffbf3a1
34 changed files with 694 additions and 655 deletions
+12 -9
View File
@@ -6,7 +6,7 @@ matrix:
compiler: clang compiler: clang
- os: linux - os: linux
env: BUILD_DPKG_PACKAGE=y env: BUILD_DPKG_PACKAGE=y CFLAGS="-Werror"
compiler: gcc compiler: gcc
dist: bionic dist: bionic
addons: addons:
@@ -21,7 +21,7 @@ matrix:
- autogen - autogen
- os: linux - os: linux
env: DISABLE_GCRYPT=y env: DISABLE_GCRYPT=y CFLAGS="-Werror"
compiler: gcc compiler: gcc
dist: bionic dist: bionic
addons: addons:
@@ -36,6 +36,7 @@ matrix:
- autogen - autogen
- os: linux - os: linux
env: CFLAGS="-Werror"
compiler: clang compiler: clang
dist: bionic dist: bionic
addons: addons:
@@ -47,6 +48,7 @@ matrix:
- autogen - autogen
- os: linux - os: linux
env: CFLAGS="-Werror"
compiler: gcc compiler: gcc
dist: bionic dist: bionic
arch: arm64 arch: arm64
@@ -59,6 +61,7 @@ matrix:
- autogen - autogen
- os: linux - os: linux
env: CFLAGS="-Werror"
compiler: clang compiler: clang
dist: bionic dist: bionic
arch: arm64 arch: arm64
@@ -107,7 +110,7 @@ matrix:
- libjson-c-dev - libjson-c-dev
- autogen - autogen
env: env:
- MATRIX_EVAL="CC=gcc-8" - MATRIX_EVAL="CC=gcc-8" CFLAGS="-Werror"
- os: linux - os: linux
compiler: gcc-9 compiler: gcc-9
@@ -122,7 +125,7 @@ matrix:
- libjson-c-dev - libjson-c-dev
- autogen - autogen
env: env:
- MATRIX_EVAL="CC=gcc-9" - MATRIX_EVAL="CC=gcc-9" CFLAGS="-Werror"
- os: linux - os: linux
compiler: clang-8 compiler: clang-8
@@ -138,7 +141,7 @@ matrix:
- libjson-c-dev - libjson-c-dev
- autogen - autogen
env: env:
- MATRIX_EVAL="CC=clang-8" - MATRIX_EVAL="CC=clang-8" CFLAGS="-Werror"
- os: linux - os: linux
compiler: clang-7 compiler: clang-7
@@ -154,10 +157,10 @@ matrix:
- libjson-c-dev - libjson-c-dev
- autogen - autogen
env: env:
- MATRIX_EVAL="CC=clang-7" - MATRIX_EVAL="CC=clang-7" CFLAGS="-Werror"
- name: fuzza - name: fuzza
env: CXXFLAGS="-g3 -O0 -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=address -fsanitize=fuzzer-no-link" CFLAGS="-g3 -O0 -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=address -fsanitize=fuzzer-no-link" LDFLAGS="-g3 -O0 -fsanitize=address" QA_FUZZ=asan CC=clang-7 && CXX=clang++-7 ASAN_SYMBOLIZER_PATH=/usr/local/clang-7.0.0/bin/llvm-symbolizer env: CXXFLAGS="-Werror -g3 -O0 -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=address -fsanitize=fuzzer-no-link" CFLAGS="-Werror -g3 -O0 -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=address -fsanitize=fuzzer-no-link" LDFLAGS="-g3 -O0 -fsanitize=address" QA_FUZZ=asan CC=clang-7 && CXX=clang++-7 ASAN_SYMBOLIZER_PATH=/usr/local/clang-7.0.0/bin/llvm-symbolizer
os: linux os: linux
compiler: clang-7 compiler: clang-7
addons: addons:
@@ -172,7 +175,7 @@ matrix:
- libjson-c-dev - libjson-c-dev
- autogen - autogen
- name: fuzzm - name: fuzzm
env: CXXFLAGS="-g3 -O0 -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=memory -fsanitize=fuzzer-no-link" CFLAGS="-g3 -O0 -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=memory -fsanitize=fuzzer-no-link" LDFLAGS="-g3 -O0 -fsanitize=memory" QA_FUZZ=msan CC=clang && CXX=clang++ env: CXXFLAGS="-Werror -g3 -O0 -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=memory -fsanitize=fuzzer-no-link" CFLAGS="-Werror -g3 -O0 -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=memory -fsanitize=fuzzer-no-link" LDFLAGS="-g3 -O0 -fsanitize=memory" QA_FUZZ=msan CC=clang && CXX=clang++
os: linux os: linux
compiler: clang compiler: clang
dist: bionic dist: bionic
@@ -184,7 +187,7 @@ matrix:
- libjson-c-dev - libjson-c-dev
- autogen - autogen
- name: fuzzu - name: fuzzu
env: CXXFLAGS="-g3 -Og -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=undefined -fsanitize=fuzzer-no-link -fno-sanitize=alignment" CFLAGS="-g3 -Og -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=undefined -fno-sanitize-recover=undefined,integer -fsanitize=fuzzer-no-link -fno-sanitize=alignment" LDFLAGS="-g3 -Og -fsanitize=undefined -fno-sanitize=alignment" QA_FUZZ=ubsan CC=clang-7 && CXX=clang++-7 env: CXXFLAGS="-Werror -g3 -Og -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=undefined -fsanitize=fuzzer-no-link -fno-sanitize=alignment" CFLAGS="-Werror -g3 -Og -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=undefined -fno-sanitize-recover=undefined,integer -fsanitize=fuzzer-no-link -fno-sanitize=alignment" LDFLAGS="-g3 -Og -fsanitize=undefined -fno-sanitize=alignment" QA_FUZZ=ubsan CC=clang-7 && CXX=clang++-7
os: linux os: linux
compiler: clang-7 compiler: clang-7
addons: addons:
+2 -2
View File
@@ -21,7 +21,7 @@ AS_IF([test "x$enable_fuzztargets" = "xyes"], [BUILD_FUZZTARGETS=1], [BUILD_FUZZ
AM_CONDITIONAL([BUILD_FUZZTARGETS], [test "x$enable_fuzztargets" = "xyes"]) AM_CONDITIONAL([BUILD_FUZZTARGETS], [test "x$enable_fuzztargets" = "xyes"])
AS_IF([test "${with_sanitizer+set}" = set],[ AS_IF([test "${with_sanitizer+set}" = set],[
CFLAGS="${CFLAGS} -g3 -O0 -Wno-unused-value -fsanitize=address -fsanitize=undefined -fno-sanitize=alignment -fsanitize=leak -fno-omit-frame-pointer" CFLAGS="${CFLAGS} -g3 -O0 -fsanitize=address -fsanitize=undefined -fno-sanitize=alignment -fsanitize=leak -fno-omit-frame-pointer"
LDFLAGS="${LDFLAGS} -fsanitize=address -fsanitize=undefined -fno-sanitize=alignment -fsanitize=leak" LDFLAGS="${LDFLAGS} -fsanitize=address -fsanitize=undefined -fno-sanitize=alignment -fsanitize=leak"
]) ])
@@ -100,7 +100,7 @@ if ! test "${with_only_libndpi+set}" = set; then :
fi fi
LIBS="$LIBS $JSONC_LIBS" LIBS="$LIBS $JSONC_LIBS"
CFLAGS="$CFLAGS $JSONC_CFLAGS" CFLAGS="-W -Wall -Wno-unused-parameter $CFLAGS $JSONC_CFLAGS"
AC_CHECK_HEADERS([netinet/in.h stdint.h stdlib.h string.h unistd.h math.h float.h]) AC_CHECK_HEADERS([netinet/in.h stdint.h stdlib.h string.h unistd.h math.h float.h])
AC_CHECK_LIB([m], [sqrt], [], [LIBM="-lm"]) AC_CHECK_LIB([m], [sqrt], [], [LIBM="-lm"])
+2 -1
View File
@@ -44,7 +44,8 @@ double normalize(ndpi_norm_value* tresholds){
double get_flow_score(ndpi_norm_value* scores, int n_metrics){ double get_flow_score(ndpi_norm_value* scores, int n_metrics){
double flow_score = 0; double flow_score = 0;
for(int i=0; i<n_metrics; i++){ int i;
for(i=0; i<n_metrics; i++){
flow_score += normalize(&scores[i]); flow_score += normalize(&scores[i]);
} }
return flow_score; return flow_score;
+39 -14
View File
@@ -66,7 +66,9 @@
/** Client parameters **/ /** Client parameters **/
static char *_pcap_file[MAX_NUM_READER_THREADS]; /**< Ingress pcap file/interfaces */ static char *_pcap_file[MAX_NUM_READER_THREADS]; /**< Ingress pcap file/interfaces */
#ifndef USE_DPDK
static FILE *playlist_fp[MAX_NUM_READER_THREADS] = { NULL }; /**< Ingress playlist */ static FILE *playlist_fp[MAX_NUM_READER_THREADS] = { NULL }; /**< Ingress playlist */
#endif
static FILE *results_file = NULL; static FILE *results_file = NULL;
static char *results_path = NULL; static char *results_path = NULL;
static char * bpfFilter = NULL; /**< bpf filter */ static char * bpfFilter = NULL; /**< bpf filter */
@@ -99,7 +101,10 @@ static struct timeval startup_time, begin, end;
static int core_affinity[MAX_NUM_READER_THREADS]; static int core_affinity[MAX_NUM_READER_THREADS];
#endif #endif
static struct timeval pcap_start = { 0, 0}, pcap_end = { 0, 0 }; static struct timeval pcap_start = { 0, 0}, pcap_end = { 0, 0 };
static struct bpf_program bpf_code,*bpf_cfilter = NULL; #ifndef USE_DPDK
static struct bpf_program bpf_code;
#endif
static struct bpf_program *bpf_cfilter = NULL;
/** Detection parameters **/ /** Detection parameters **/
static time_t capture_for = 0; static time_t capture_for = 0;
static time_t capture_until = 0; static time_t capture_until = 0;
@@ -779,12 +784,15 @@ void printCSVHeader() {
* @brief Option parser * @brief Option parser
*/ */
static void parseOptions(int argc, char **argv) { static void parseOptions(int argc, char **argv) {
int option_idx = 0, do_capture = 0; int option_idx = 0;
int opt;
#ifndef USE_DPDK
char *__pcap_file = NULL, *bind_mask = NULL; char *__pcap_file = NULL, *bind_mask = NULL;
int thread_id, opt; int thread_id, do_capture = 0;
#ifdef linux #ifdef linux
u_int num_cores = sysconf(_SC_NPROCESSORS_ONLN); u_int num_cores = sysconf(_SC_NPROCESSORS_ONLN);
#endif #endif
#endif
#ifdef USE_DPDK #ifdef USE_DPDK
{ {
@@ -847,9 +855,11 @@ static void parseOptions(int argc, char **argv) {
bpfFilter = optarg; bpfFilter = optarg;
break; break;
#ifndef USE_DPDK
case 'g': case 'g':
bind_mask = optarg; bind_mask = optarg;
break; break;
#endif
case 'l': case 'l':
num_loops = atoi(optarg); num_loops = atoi(optarg);
@@ -969,9 +979,11 @@ static void parseOptions(int argc, char **argv) {
extcap_config(); extcap_config();
break; break;
#ifndef USE_DPDK
case '5': case '5':
do_capture = 1; do_capture = 1;
break; break;
#endif
case '7': case '7':
extcap_capture_fifo = strdup(optarg); extcap_capture_fifo = strdup(optarg);
@@ -1668,7 +1680,8 @@ int updateIpTree(u_int32_t key, u_int8_t version,
q->addr = key; q->addr = key;
q->version = version; q->version = version;
strncpy(q->proto, proto, sizeof(q->proto)); strncpy(q->proto, proto, sizeof(q->proto) - 1);
q->proto[sizeof(q->proto) - 1] = '\0';
q->count = UPDATED_TREE; q->count = UPDATED_TREE;
q->left = q->right = (addr_node *)0; q->left = q->right = (addr_node *)0;
@@ -1703,7 +1716,8 @@ void updateTopIpAddress(u_int32_t addr, u_int8_t version, const char *proto,
pair.addr = addr; pair.addr = addr;
pair.version = version; pair.version = version;
pair.count = count; pair.count = count;
strncpy(pair.proto, proto, sizeof(pair.proto)); strncpy(pair.proto, proto, sizeof(pair.proto) - 1);
pair.proto[sizeof(pair.proto) - 1] = '\0';
for(i=0; i<size; i++) { for(i=0; i<size; i++) {
/* if the same ip with a bigger /* if the same ip with a bigger
@@ -1761,7 +1775,8 @@ static void updatePortStats(struct port_stats **stats, u_int32_t port,
s->addr_tree->addr = addr; s->addr_tree->addr = addr;
s->addr_tree->version = version; s->addr_tree->version = version;
strncpy(s->addr_tree->proto, proto, sizeof(s->addr_tree->proto)); strncpy(s->addr_tree->proto, proto, sizeof(s->addr_tree->proto) - 1);
s->addr_tree->proto[sizeof(s->addr_tree->proto) - 1] = '\0';
s->addr_tree->count = 1; s->addr_tree->count = 1;
s->addr_tree->left = NULL; s->addr_tree->left = NULL;
s->addr_tree->right = NULL; s->addr_tree->right = NULL;
@@ -1971,12 +1986,14 @@ static void port_stats_walker(const void *node, ndpi_VISIT which, int depth, voi
sport = ntohs(flow->src_port), dport = ntohs(flow->dst_port); sport = ntohs(flow->src_port), dport = ntohs(flow->dst_port);
/* get app level protocol */ /* get app level protocol */
if(flow->detected_protocol.master_protocol) if(flow->detected_protocol.master_protocol) {
ndpi_protocol2name(ndpi_thread_info[thread_id].workflow->ndpi_struct, ndpi_protocol2name(ndpi_thread_info[thread_id].workflow->ndpi_struct,
flow->detected_protocol, proto, sizeof(proto)); flow->detected_protocol, proto, sizeof(proto));
else } else {
strncpy(proto, ndpi_get_proto_name(ndpi_thread_info[thread_id].workflow->ndpi_struct, strncpy(proto, ndpi_get_proto_name(ndpi_thread_info[thread_id].workflow->ndpi_struct,
flow->detected_protocol.app_protocol),sizeof(proto)); flow->detected_protocol.app_protocol),sizeof(proto) - 1);
proto[sizeof(proto) - 1] = '\0';
}
if(((r = strcmp(ipProto2Name(flow->protocol), "TCP")) == 0) if(((r = strcmp(ipProto2Name(flow->protocol), "TCP")) == 0)
&& (flow->src2dst_packets == 1) && (flow->dst2src_packets == 0)) { && (flow->src2dst_packets == 1) && (flow->dst2src_packets == 0)) {
@@ -2354,7 +2371,7 @@ static void printFlowsStats() {
ndpi_host_ja3_fingerprints *ja3ByHostsHashT = NULL; // outer hash table ndpi_host_ja3_fingerprints *ja3ByHostsHashT = NULL; // outer hash table
ndpi_ja3_fingerprints_host *hostByJA3C_ht = NULL; // for client ndpi_ja3_fingerprints_host *hostByJA3C_ht = NULL; // for client
ndpi_ja3_fingerprints_host *hostByJA3S_ht = NULL; // for server ndpi_ja3_fingerprints_host *hostByJA3S_ht = NULL; // for server
int i; unsigned int i;
ndpi_host_ja3_fingerprints *ja3ByHost_element = NULL; ndpi_host_ja3_fingerprints *ja3ByHost_element = NULL;
ndpi_ja3_info *info_of_element = NULL; ndpi_ja3_info *info_of_element = NULL;
ndpi_host_ja3_fingerprints *tmp = NULL; ndpi_host_ja3_fingerprints *tmp = NULL;
@@ -2860,7 +2877,7 @@ static void printFlowsStats() {
for(i=0; i<num_flows; i++) for(i=0; i<num_flows; i++)
printFlow(i+1, all_flows[i].flow, all_flows[i].thread_id); printFlow(i+1, all_flows[i].flow, all_flows[i].thread_id);
} else if(csv_fp != NULL) { } else if(csv_fp != NULL) {
int i; unsigned int i;
num_flows = 0; num_flows = 0;
for(thread_id = 0; thread_id < num_threads; thread_id++) { for(thread_id = 0; thread_id < num_threads; thread_id++) {
@@ -3165,6 +3182,8 @@ void sigproc(int sig) {
} }
#ifndef USE_DPDK
/** /**
* @brief Get the next pcap file from a passed playlist * @brief Get the next pcap file from a passed playlist
*/ */
@@ -3188,7 +3207,6 @@ next_line:
} }
} }
/** /**
* @brief Configure the pcap handle * @brief Configure the pcap handle
*/ */
@@ -3211,14 +3229,17 @@ static void configurePcapHandle(pcap_t * pcap_handle) {
} }
} }
#endif
/** /**
* @brief Open a pcap file or a specified device - Always returns a valid pcap_t * @brief Open a pcap file or a specified device - Always returns a valid pcap_t
*/ */
static pcap_t * openPcapFileOrDevice(u_int16_t thread_id, const u_char * pcap_file) { static pcap_t * openPcapFileOrDevice(u_int16_t thread_id, const u_char * pcap_file) {
#ifndef USE_DPDK
u_int snaplen = 1536; u_int snaplen = 1536;
int promisc = 1; int promisc = 1;
char pcap_error_buffer[PCAP_ERRBUF_SIZE]; char pcap_error_buffer[PCAP_ERRBUF_SIZE];
#endif
pcap_t * pcap_handle = NULL; pcap_t * pcap_handle = NULL;
/* trying to open a live interface */ /* trying to open a live interface */
@@ -3386,8 +3407,8 @@ static void ndpi_process_packet(u_char *args,
printf("INTERNAL ERROR: ingress packet was modified by nDPI: this should not happen [thread_id=%u, packetId=%lu, caplen=%u]\n", printf("INTERNAL ERROR: ingress packet was modified by nDPI: this should not happen [thread_id=%u, packetId=%lu, caplen=%u]\n",
thread_id, (unsigned long)ndpi_thread_info[thread_id].workflow->stats.raw_packet_count, header->caplen); thread_id, (unsigned long)ndpi_thread_info[thread_id].workflow->stats.raw_packet_count, header->caplen);
if((pcap_end.tv_sec-pcap_start.tv_sec) > pcap_analysis_duration) { if((u_int32_t)(pcap_end.tv_sec-pcap_start.tv_sec) > pcap_analysis_duration) {
int i; unsigned int i;
u_int64_t processing_time_usec, setup_time_usec; u_int64_t processing_time_usec, setup_time_usec;
gettimeofday(&end, NULL); gettimeofday(&end, NULL);
@@ -3420,6 +3441,7 @@ static void ndpi_process_packet(u_char *args,
} }
} }
#ifndef USE_DPDK
/** /**
* @brief Call pcap_loop() to process packets from a live capture or savefile * @brief Call pcap_loop() to process packets from a live capture or savefile
*/ */
@@ -3435,13 +3457,16 @@ static void runPcapLoop(u_int16_t thread_id) {
printf("Error while reading pcap file: '%s'\n", pcap_geterr(ndpi_thread_info[thread_id].workflow->pcap_handle)); printf("Error while reading pcap file: '%s'\n", pcap_geterr(ndpi_thread_info[thread_id].workflow->pcap_handle));
} }
} }
#endif
/** /**
* @brief Process a running thread * @brief Process a running thread
*/ */
void * processing_thread(void *_thread_id) { void * processing_thread(void *_thread_id) {
long thread_id = (long) _thread_id; long thread_id = (long) _thread_id;
#ifndef USE_DPDK
char pcap_error_buffer[PCAP_ERRBUF_SIZE]; char pcap_error_buffer[PCAP_ERRBUF_SIZE];
#endif
#if defined(linux) && defined(HAVE_PTHREAD_SETAFFINITY_NP) #if defined(linux) && defined(HAVE_PTHREAD_SETAFFINITY_NP)
if(core_affinity[thread_id] >= 0) { if(core_affinity[thread_id] >= 0) {
+4 -2
View File
@@ -1008,7 +1008,8 @@ static u_int8_t is_ndpi_proto(struct ndpi_flow_info *flow, u_int16_t id) {
void correct_csv_data_field(char* data) { void correct_csv_data_field(char* data) {
/* Replace , with ; to avoid issues with CSVs */ /* Replace , with ; to avoid issues with CSVs */
for(u_int i=0; data[i] != '\0'; i++) if(data[i] == ',') data[i] = ';'; u_int i;
for(i=0; data[i] != '\0'; i++) if(data[i] == ',') data[i] = ';';
} }
/* ****************************************************** */ /* ****************************************************** */
@@ -1621,7 +1622,7 @@ struct ndpi_proto ndpi_workflow_process_packet(struct ndpi_workflow * workflow,
ndpi_packet_tunnel tunnel_type = ndpi_no_tunnel; ndpi_packet_tunnel tunnel_type = ndpi_no_tunnel;
/* lengths and offsets */ /* lengths and offsets */
u_int16_t eth_offset = 0; u_int32_t eth_offset = 0;
u_int16_t radio_len; u_int16_t radio_len;
u_int16_t fc; u_int16_t fc;
u_int16_t type = 0; u_int16_t type = 0;
@@ -2172,6 +2173,7 @@ int dpdk_port_init(int port, struct rte_mempool *mbuf_pool) {
int dpdk_port_deinit(int port) { int dpdk_port_deinit(int port) {
rte_eth_dev_stop(port); rte_eth_dev_stop(port);
rte_eth_dev_close(port); rte_eth_dev_close(port);
return 0;
} }
#endif #endif
+1 -1
View File
@@ -159,7 +159,7 @@ int main(int argc, char ** argv)
return 1; return 1;
} }
if (fread(pcap_buffer, sizeof(*pcap_buffer), pcap_file_size, pcap_file) != pcap_file_size) { if (fread(pcap_buffer, sizeof(*pcap_buffer), pcap_file_size, pcap_file) != (size_t)pcap_file_size) {
perror("fread failed"); perror("fread failed");
fclose(pcap_file); fclose(pcap_file);
free(pcap_buffer); free(pcap_buffer);
+1 -1
View File
@@ -687,7 +687,7 @@ extern "C" {
* *
* @par ndpi_mod = the detection module * @par ndpi_mod = the detection module
*/ */
void ndpi_dump_risks_score(); void ndpi_dump_risks_score(void);
/** /**
* Read a file and load the protocols * Read a file and load the protocols
+3 -1
View File
@@ -1512,12 +1512,14 @@ struct ndpi_flow_struct {
struct ndpi_id_struct *dst; struct ndpi_id_struct *dst;
}; };
#define NDPI_PROTOCOL_DEFAULT_LEVEL 0
typedef struct { typedef struct {
char *string_to_match, *proto_name; char *string_to_match, *proto_name;
u_int16_t protocol_id; u_int16_t protocol_id;
ndpi_protocol_category_t protocol_category; ndpi_protocol_category_t protocol_category;
ndpi_protocol_breed_t protocol_breed; ndpi_protocol_breed_t protocol_breed;
int level; /* 0 by default */ int level; /* NDPI_PROTOCOL_DEFAULT_LEVEL (0) by default */
} ndpi_protocol_match; } ndpi_protocol_match;
typedef struct { typedef struct {
+1 -1
View File
@@ -13,7 +13,7 @@ prefix = @prefix@
libdir = ${prefix}/lib libdir = ${prefix}/lib
includedir = ${prefix}/include/ndpi includedir = ${prefix}/include/ndpi
CC = @GNU_PREFIX@@CC@ 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@ LDFLAGS = @LDFLAGS@ @ADDITIONAL_LIBS@ @LIBS@
RANLIB = @GNU_PREFIX@ranlib RANLIB = @GNU_PREFIX@ranlib
+1 -1
View File
@@ -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, 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, 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; u_int8_t pad = 0;
uint32_t hash[5]; uint32_t hash[5];
char *community_id; char *community_id;
File diff suppressed because it is too large Load Diff
+22 -21
View File
@@ -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 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; unsigned int i,j,c;
for(i=0;i < sn && src[i]; i++) { for(i=0;i < sn && src[i]; i++) {
for(j=0,c=0; j < l; j++) { 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) { static void ndpi_validate_protocol_initialization(struct ndpi_detection_module_struct *ndpi_str) {
u_int i, val; 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) { if(ndpi_str->proto_defaults[i].protoName == NULL) {
NDPI_LOG_ERR(ndpi_str, NDPI_LOG_ERR(ndpi_str,
"[NDPI] INTERNAL ERROR missing protoName initialization for [protoId=%d]: recovering\n", i); "[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, 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, u_int32_t *protocol_id, ndpi_protocol_category_t *category,
ndpi_protocol_breed_t *breed) { 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; AC_TEXT_t ac_input_text;
int rc; 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, int ndpi_match_string_value(void *automa, char *string_to_match,
u_int match_len, u_int32_t *num) { u_int match_len, u_int32_t *num) {
int rc = ndpi_match_string_common((AC_AUTOMATA_t *)automa, string_to_match, int rc = ndpi_match_string_common((AC_AUTOMATA_t *)automa, string_to_match,
match_len, num, NULL, NULL); match_len, num, NULL, NULL);
if(rc < 0) return rc; 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 buffer[128];
char *first_comma, *second_comma, *str; char *first_comma, *second_comma, *str;
FILE *fd; FILE *fd;
size_t len; size_t i, len;
int num = 0; int num = 0;
if (ndpi_str->malicious_sha1_automa.ac_automa == NULL) 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; continue;
second_comma[0] = '\0'; 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]); first_comma[i] = toupper(first_comma[i]);
str = ndpi_strdup(first_comma); 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_index = ndpi_str->proto_defaults[flow->guessed_protocol_id].protoIdx;
u_int16_t proto_id = ndpi_str->proto_defaults[flow->guessed_protocol_id].protoId; u_int16_t proto_id = ndpi_str->proto_defaults[flow->guessed_protocol_id].protoId;
NDPI_PROTOCOL_BITMASK detection_bitmask; NDPI_PROTOCOL_BITMASK detection_bitmask;
u_int32_t a;
NDPI_SAVE_AS_BITMASK(detection_bitmask, flow->packet.detected_protocol_stack[0]); 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) 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) && if ((func != callback_buffer[a].func) &&
(callback_buffer[a].ndpi_selection_bitmask & ndpi_selection_packet) == (callback_buffer[a].ndpi_selection_bitmask & ndpi_selection_packet) ==
callback_buffer[a].ndpi_selection_bitmask && 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. */ /* 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]; 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) 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; a = NDPI_PROTOCOL_UNKNOWN;
if(a != NDPI_PROTOCOL_UNKNOWN) { if(a != NDPI_PROTOCOL_UNKNOWN) {
int i; unsigned int i;
for(i = 0; i < sizeof(flow->host_server_name); i++) { for(i = 0; i < sizeof(flow->host_server_name); i++) {
if(flow->host_server_name[i] != '\0') 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; diff = packet->payload_packet_len - a1;
if(diff > 0) { 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); memcpy(&flow->initial_binary_bytes, &packet->payload[a1], diff);
flow->initial_binary_bytes_len = diff; flow->initial_binary_bytes_len = diff;
} }
@@ -6779,7 +6779,7 @@ void ndpi_dump_risks_score() {
for(i = 1; i < NDPI_MAX_RISK; i++) { for(i = 1; i < NDPI_MAX_RISK; i++) {
ndpi_risk_enum r = (ndpi_risk_enum)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_info* info = ndpi_risk2severity(r);
ndpi_risk_severity s =info->severity; ndpi_risk_severity s =info->severity;
u_int16_t client_score, server_score; 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), rc = ndpi_match_string_common(((AC_AUTOMATA_t *) automa->ac_automa),
string_to_match,string_to_match_len, &ret_match->protocol_id, string_to_match,string_to_match_len, &ret_match->protocol_id,
&ret_match->protocol_category, &ret_match->protocol_breed); &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; unsigned int i,c;
for(i=0,c=0; *str && i < l; i++) { for(i=0,c=0; *str && i < l; i++) {
unsigned char a = (unsigned char)(*str++); 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 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++) { for(i = 0; i < NDPI_NUM_FDS_BITS; i++) {
if(a.fds_bits[i] & b.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 #ifdef CODE_UNUSED
int NDPI_BITMASK_IS_EMPTY(NDPI_PROTOCOL_BITMASK a) { int NDPI_BITMASK_IS_EMPTY(NDPI_PROTOCOL_BITMASK a) {
int i; unsigned int i;
for(i = 0; i < NDPI_NUM_FDS_BITS; i++) for(i = 0; i < NDPI_NUM_FDS_BITS; i++)
if(a.fds_bits[i] != 0) 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) { void NDPI_DUMP_BITMASK(NDPI_PROTOCOL_BITMASK a) {
int i; unsigned int i;
for(i = 0; i < NDPI_NUM_FDS_BITS; i++) for(i = 0; i < NDPI_NUM_FDS_BITS; i++)
printf("[%d=%u]", i, a.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); len = strlen(name);
if(len >= 5) { 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_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; num_digits = 0, num_vowels = 0, num_trigram_vowels = 0, num_words = 0, skip_next_bigram = 0;
char tmp[128], *word, *tok_tmp; 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); len = snprintf(tmp, max_tmp_len, "%s", name);
if(len < 0) { if(len < 0) {
@@ -7522,9 +7522,9 @@ int ndpi_check_dga_name(struct ndpi_detection_module_struct *ndpi_str,
return(0); return(0);
} else } 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]); tmp[j] = tolower(name[i]);
if(tmp[j] == '.') { if(tmp[j] == '.') {
@@ -7546,7 +7546,7 @@ int ndpi_check_dga_name(struct ndpi_detection_module_struct *ndpi_str,
if(isdigit(tmp[j])) { if(isdigit(tmp[j])) {
num_digits++; 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 */ /* Check if there are too many digits */
if(num_digits < 4) if(num_digits < 4)
return(0); /* Double digits */ return(0); /* Double digits */
@@ -7646,6 +7646,7 @@ int ndpi_check_dga_name(struct ndpi_detection_module_struct *ndpi_str,
*/ */
if(word[i+1] == '-') if(word[i+1] == '-')
return(0); /* Double dash */ return(0); /* Double dash */
continue;
case '_': case '_':
case ':': case ':':
+1 -1
View File
@@ -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) { 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++) for(i = 0; i < str_len; i++)
if(!isdigit(str[i])) return(0); if(!isdigit(str[i])) return(0);
+3 -3
View File
@@ -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) { char* ndpi_base64_encode(unsigned char const* bytes_to_encode, size_t in_len) {
size_t len = 0, ret_size; size_t len = 0, ret_size;
char *ret; char *ret;
int i = 0; int j, i = 0;
unsigned char char_array_3[3]; unsigned char char_array_3[3];
unsigned char char_array_4[4]; 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) { if(i) {
for(int j = i; j < 3; j++) for(j = i; j < 3; j++)
char_array_3[j] = '\0'; char_array_3[j] = '\0';
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; 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[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
char_array_4[3] = char_array_3[2] & 0x3f; 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]]; ret[len++] = base64_table[char_array_4[j]];
while((i++ < 3)) while((i++ < 3))
+1 -1
View File
@@ -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; if(c != ':') goto bad_data;
break; break;
} }
if(d > *l) goto bad_data; if((size_t)d > *l) goto bad_data;
cbd->t = 2; cbd->t = 2;
cbd->v.s.s = b; cbd->v.s.s = b;
cbd->v.s.l = d; cbd->v.s.l = d;
+1 -1
View File
@@ -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 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_int32_t i = 4;
u_int16_t bytes_read = 0; u_int16_t bytes_read = 0;
+3 -2
View File
@@ -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) { if(packet->content_disposition_line.len > attachment_len) {
u_int8_t filename_len = 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) { if(filename_len > ATTACHMENT_LEN) {
attachment_len += filename_len-ATTACHMENT_LEN-1; attachment_len += filename_len-ATTACHMENT_LEN-1;
if((attachment_len+ATTACHMENT_LEN) <= packet->content_disposition_line.len) { 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 */ /* Use memcmp in case content-disposition contains binary data */
if(memcmp(&packet->content_disposition_line.ptr[attachment_len], if(memcmp(&packet->content_disposition_line.ptr[attachment_len],
binary_file_ext[i], ATTACHMENT_LEN) == 0) { 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) 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; 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", NDPI_LOG_DBG2(ndpi_struct, "====>>>> HTTP: %c%c%c%c [len: %u]\n",
packet->payload_packet_len > 0 ? non_ctrl(packet->payload[0]) : '.', packet->payload_packet_len > 0 ? non_ctrl(packet->payload[0]) : '.',
+1 -1
View File
@@ -302,7 +302,7 @@ void ndpi_search_kerberos(struct ndpi_detection_module_struct *ndpi_struct,
#endif #endif
if(body_offset < packet->payload_packet_len) { 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; name_offset = padding_offset;
for(i=0; i<14; i++) if(packet->payload[name_offset] != 0x1b) name_offset++; /* ASN.1 */ for(i=0; i<14; i++) if(packet->payload[name_offset] != 0x1b) name_offset++; /* ASN.1 */
+2 -1
View File
@@ -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(flow->host_server_name[0] == '\0') {
if(packet->line[a].len > 4) { if(packet->line[a].len > 4) {
int i, len; int i;
unsigned int len;
if(packet->line[a].ptr[4] != '(') { if(packet->line[a].ptr[4] != '(') {
for(i=5; (i<packet->line[a].len-1) && (packet->line[a].ptr[i] != ' '); i++) for(i=5; (i<packet->line[a].len-1) && (packet->line[a].ptr[i] != ' '); i++)
+1 -1
View File
@@ -172,7 +172,7 @@ void ndpi_search_netflow(struct ndpi_detection_module_struct *ndpi_struct, struc
now = now_tv.tv_sec; now = now_tv.tv_sec;
if(((version == 1) && (when == 0)) 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_LOG_INFO(ndpi_struct, "found netflow\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_NETFLOW, NDPI_PROTOCOL_UNKNOWN); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_NETFLOW, NDPI_PROTOCOL_UNKNOWN);
return; return;
+3 -3
View File
@@ -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 (flow->l4.tcp.postgres_stage == 4 - packet->packet_direction)
if (packet->payload_packet_len > 8 && if (packet->payload_packet_len > 8 &&
ntohl(get_u_int32_t(packet->payload, 5)) < 10 && 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_LOG_INFO(ndpi_struct, "PostgreSQL detected, no SSL\n");
ndpi_int_postgres_add_connection(ndpi_struct, flow); ndpi_int_postgres_add_connection(ndpi_struct, flow);
return; return;
} }
if (flow->l4.tcp.postgres_stage == 6 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_LOG_INFO(ndpi_struct, "found postgres asymmetrically\n");
ndpi_int_postgres_add_connection(ndpi_struct, flow); ndpi_int_postgres_add_connection(ndpi_struct, flow);
return; return;
} }
if (flow->l4.tcp.postgres_stage == 5 && packet->payload[0] == 'R') { 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_LOG_INFO(ndpi_struct, "found postgres asymmetrically\n");
ndpi_int_postgres_add_connection(ndpi_struct, flow); ndpi_int_postgres_add_connection(ndpi_struct, flow);
return; return;
+2 -2
View File
@@ -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, uint64_t frag_len, uint64_t frag_offset,
const u_int8_t **buf, u_int64_t *buf_len) 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. /* 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 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_int32_t version;
u_int8_t *clear_payload; u_int8_t *clear_payload;
uint32_t clear_payload_len; uint32_t clear_payload_len = 0;
const u_int8_t *crypto_data; const u_int8_t *crypto_data;
uint64_t crypto_data_len; uint64_t crypto_data_len;
int is_quic; int is_quic;
+26 -26
View File
@@ -48,19 +48,19 @@ struct ndpi_rx_header {
} PACK_OFF; } PACK_OFF;
/* Type values */ /* Type values */
#define DATA 1 #define RX_DATA 1
#define ACK 2 #define RX_ACK 2
#define BUSY 3 #define RX_BUSY 3
#define ABORT 4 #define RX_ABORT 4
#define ACKALL 5 #define RX_ACKALL 5
#define CHALLENGE 6 #define RX_CHALLENGE 6
#define RESPONSE 7 #define RX_RESPONSE 7
#define DEBUG 8 #define RX_DEBUG 8
#define PARAM_1 9 #define RX_PARAM_1 9
#define PARAM_2 10 #define RX_PARAM_2 10
#define PARAM_3 11 #define RX_PARAM_3 11
#define PARAMS_4 12 #define RX_PARAMS_4 12
#define VERS 13 #define RX_VERS 13
/* Flags values */ /* Flags values */
#define EMPTY 0 #define EMPTY 0
@@ -108,7 +108,7 @@ void ndpi_check_rx(struct ndpi_detection_module_struct *ndpi_struct,
**/ **/
/* TYPE field */ /* TYPE field */
if((header->type < DATA) || (header->type > VERS)) { if((header->type < RX_DATA) || (header->type > RX_VERS)) {
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
return; return;
} }
@@ -123,43 +123,43 @@ void ndpi_check_rx(struct ndpi_detection_module_struct *ndpi_struct,
/* TYPE and FLAGS combo */ /* TYPE and FLAGS combo */
switch(header->type) switch(header->type)
{ {
case DATA: case RX_DATA:
if(header->flags == LAST_PKT || header->flags == EMPTY || if(header->flags == LAST_PKT || header->flags == EMPTY ||
header->flags == PLUS_0 || header->flags == PLUS_1 || header->flags == PLUS_0 || header->flags == PLUS_1 ||
header->flags == PLUS_2 || header->flags == REQ_ACK || header->flags == PLUS_2 || header->flags == REQ_ACK ||
header->flags == MORE_1) header->flags == MORE_1)
goto security; goto security;
/* Fall-through */ /* Fall-through */
case ACK: case RX_ACK:
if(header->flags == CLIENT_INIT_1 || header->flags == CLIENT_INIT_2 || if(header->flags == CLIENT_INIT_1 || header->flags == CLIENT_INIT_2 ||
header->flags == EMPTY) header->flags == EMPTY)
goto security; goto security;
/* Fall-through */ /* Fall-through */
case CHALLENGE: case RX_CHALLENGE:
if(header->flags == EMPTY || header->call_number == 0) if(header->flags == EMPTY || header->call_number == 0)
goto security; goto security;
/* Fall-through */ /* Fall-through */
case RESPONSE: case RX_RESPONSE:
if(header->flags == EMPTY || header->call_number == 0) if(header->flags == EMPTY || header->call_number == 0)
goto security; goto security;
/* Fall-through */ /* Fall-through */
case ACKALL: case RX_ACKALL:
if(header->flags == EMPTY) if(header->flags == EMPTY)
goto security; goto security;
/* Fall-through */ /* Fall-through */
case BUSY: case RX_BUSY:
goto security; goto security;
case ABORT: case RX_ABORT:
goto security; goto security;
case DEBUG: case RX_DEBUG:
goto security; goto security;
case PARAM_1: case RX_PARAM_1:
goto security; goto security;
case PARAM_2: case RX_PARAM_2:
goto security; goto security;
case PARAM_3: case RX_PARAM_3:
goto security; goto security;
case VERS: case RX_VERS:
goto security; goto security;
default: default:
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
+2 -2
View File
@@ -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) { 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; struct ndpi_packet_struct *packet = &flow->packet;
u_int32_t payload_len = packet->payload_packet_len; u_int32_t payload_len = packet->payload_packet_len;
int i;
const uint8_t id_flags_iv_crc_len = 11; const uint8_t id_flags_iv_crc_len = 11;
const uint8_t crc_len = sizeof(flow->l4.udp.skype_crc); const uint8_t crc_len = sizeof(flow->l4.udp.skype_crc);
const uint8_t crc_offset = id_flags_iv_crc_len - crc_len; 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; u_int8_t detected = 1;
/* Check if both packets have the same CRC */ /* 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]) if (packet->payload[crc_offset + i] != flow->l4.udp.skype_crc[i])
detected = 0; detected = 0;
} }
+1 -1
View File
@@ -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)) if(((packet->tcp->dest == fourfourfive) || (packet->tcp->source == fourfourfive))
&& packet->payload_packet_len > (32 + 4 + 4) && 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 }; u_int8_t smbv1[] = { 0xff, 0x53, 0x4d, 0x42 };
+1 -1
View File
@@ -68,7 +68,7 @@ void ndpi_search_smpp_tcp(struct ndpi_detection_module_struct* ndpi_struct,
u_int32_t tmp_pdu_l = 0; u_int32_t tmp_pdu_l = 0;
u_int16_t pdu_c = 1; u_int16_t pdu_c = 1;
// loop PDUs (check if lengths are valid) // 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 // get next PDU length
tmp_pdu_l = ntohl(get_u_int32_t(packet->payload, total_pdu_l)); tmp_pdu_l = ntohl(get_u_int32_t(packet->payload, total_pdu_l));
// if zero or overflowing , return, will try the next TCP segment // if zero or overflowing , return, will try the next TCP segment
+6 -6
View File
@@ -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) { if(packet->payload_packet_len >= 12 && packet->payload_packet_len < 300 && get_l32(packet->payload, 4) == 1) {
while (index + 4 < packet->payload_packet_len && while (index + 4 < packet->payload_packet_len &&
!get_u_int16_t(packet->payload, index + 2) !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 */ if(get_l32(packet->payload, index) < 8) /*Minimum soulseek login msg is 8B */
break; break;
@@ -125,7 +125,7 @@ void ndpi_search_soulseek_tcp(struct ndpi_detection_module_struct *ndpi_struct,
} /* while */ } /* while */
if((packet->payload_packet_len >= (index+4)) 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)) { && (get_u_int16_t(packet->payload, 10) != 0)) {
/* This structure seems to be soulseek proto */ /* This structure seems to be soulseek proto */
index = get_l32(packet->payload, 8) + 12; // end of "user name" 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 if (packet->payload_packet_len > 8
&& (packet->payload_packet_len < 200) && (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: //Server Messages:
const u_int32_t msgcode = get_l32(packet->payload, 4); 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 //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_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_int8_t type = packet->payload[packet->payload_packet_len - 5];
const u_int32_t namelen = get_l32(packet->payload, 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)) { && !get_u_int16_t(packet->payload, 2)) {
const u_int32_t usrlen = get_l32(packet->payload, 5); 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_int32_t typelen = get_l32(packet->payload, 4 + 1 + 4 + usrlen);
const u_int8_t type = packet->payload[4 + 1 + 4 + usrlen + 4]; const u_int8_t type = packet->payload[4 + 1 + 4 + usrlen + 4];
if(typelen == 1 && (type == 'F' || type == 'P' || type == 'D')) { 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; SOULSEEK_DETECT;
return; 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); const u_int32_t msgcode = get_l32(packet->payload, 4);
if(msgcode == 0x03 && packet->payload_packet_len >= 12) //Server Message : Get Peer Address if(msgcode == 0x03 && packet->payload_packet_len >= 12) //Server Message : Get Peer Address
{ {
+6 -6
View File
@@ -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)); //printf("%08X - %08X\n", ntohl(packet->iph->saddr), ntohl(packet->iph->daddr));
long src_addr = ntohl(packet->iph->saddr); unsigned long src_addr = ntohl(packet->iph->saddr);
long dst_addr = ntohl(packet->iph->daddr); unsigned long dst_addr = ntohl(packet->iph->daddr);
long src_addr_masked_22 = src_addr & 0xFFFFFC00; // */22 unsigned long src_addr_masked_22 = src_addr & 0xFFFFFC00; // */22
long dst_addr_masked_22 = dst_addr & 0xFFFFFC00; // */22 unsigned long dst_addr_masked_22 = dst_addr & 0xFFFFFC00; // */22
long src_addr_masked_24 = src_addr & 0xFFFFFF00; // */24 unsigned long src_addr_masked_24 = src_addr & 0xFFFFFF00; // */24
long dst_addr_masked_24 = dst_addr & 0xFFFFFF00; // */24 unsigned long dst_addr_masked_24 = dst_addr & 0xFFFFFF00; // */24
if( src_addr_masked_22 == 0x4E1F0800 /* 78.31.8.0 */ if( src_addr_masked_22 == 0x4E1F0800 /* 78.31.8.0 */
|| dst_addr_masked_22 == 0x4E1F0800 /* 78.31.8.0 */ || dst_addr_masked_22 == 0x4E1F0800 /* 78.31.8.0 */
+1 -1
View File
@@ -75,7 +75,7 @@ static void ndpi_check_tinc(struct ndpi_detection_module_struct *ndpi_struct, st
case 0: case 0:
case 1: case 1:
if(payload_len > 6 && memcmp(packet_payload, "0 ", 2) == 0 && packet_payload[2] != ' ') { 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++] != ' '); while(i < payload_len && packet_payload[i++] != ' ');
if(i+3 == payload_len && memcmp((packet_payload+i), "17\n", 3) == 0) { if(i+3 == payload_len && memcmp((packet_payload+i), "17\n", 3) == 0) {
flow->tinc_state++; flow->tinc_state++;
+11 -9
View File
@@ -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; u_int i;
/* Now all lowecase */ /* Now all lowecase */
@@ -318,7 +318,7 @@ static void processCertificateElements(struct ndpi_detection_module_struct *ndpi
struct ndpi_flow_struct *flow, struct ndpi_flow_struct *flow,
u_int16_t p_offset, u_int16_t certificate_len) { u_int16_t p_offset, u_int16_t certificate_len) {
struct ndpi_packet_struct *packet = &flow->packet; 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' }; char buffer[64] = { '\0' }, rdnSeqBuf[2048] = { '\0' };
u_int rdn_len = 0; u_int rdn_len = 0;
@@ -690,7 +690,7 @@ int processCertificate(struct ndpi_detection_module_struct *ndpi_struct,
#ifdef DEBUG_CERTIFICATE_HASH #ifdef DEBUG_CERTIFICATE_HASH
{ {
int i; u_int32_t i;
for(i=0;i<certificate_len;i++) for(i=0;i<certificate_len;i++)
printf("%02X ", packet->payload[certificates_offset+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); const size_t sha1_siz = sizeof(flow->protos.tls_quic_stun.tls_quic.sha1_certificate_fingerprint);
char sha1_str[20 /* sha1_siz */ * 2 + 1]; char sha1_str[20 /* sha1_siz */ * 2 + 1];
static const char hexalnum[] = "0123456789ABCDEF"; 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 lower = (sha1[i] & 0x0F);
u_int8_t upper = (sha1[i] & 0xF0) >> 4; u_int8_t upper = (sha1[i] & 0xF0) >> 4;
sha1_str[i*2] = hexalnum[upper]; 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)) { if(!is_a_common_alpn(ndpi_struct, alpn_start, alpn_len)) {
#ifdef DEBUG_TLS #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 #endif
ndpi_set_risk(ndpi_struct, flow, NDPI_TLS_UNCOMMON_ALPN); ndpi_set_risk(ndpi_struct, flow, NDPI_TLS_UNCOMMON_ALPN);
break; break;
@@ -1348,7 +1349,7 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
printf("Server TLS [ALPN: %u]\n", alpn_len); printf("Server TLS [ALPN: %u]\n", alpn_len);
#endif #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) { if(alpn_str_len > 0) {
alpn_str[alpn_str_len] = ','; alpn_str[alpn_str_len] = ',';
alpn_str_len++; alpn_str_len++;
@@ -1823,7 +1824,8 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
continue; continue;
} else { } else {
/* Check for other duplications */ /* 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) { for(j=0; j<tot_signature_algorithms_len; j+=2) {
if(j != i) { if(j != i) {
@@ -1934,7 +1936,7 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
printf("Client TLS [ALPN: %u]\n", alpn_len); printf("Client TLS [ALPN: %u]\n", alpn_len);
#endif #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) { if(alpn_str_len > 0) {
alpn_str[alpn_str_len] = ','; alpn_str[alpn_str_len] = ',';
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_int16_t s_offset = offset+extension_offset;
u_int8_t version_len = packet->payload[s_offset]; u_int8_t version_len = packet->payload[s_offset];
char version_str[256]; char version_str[256];
u_int8_t version_str_len = 0; size_t version_str_len = 0;
version_str[0] = 0; version_str[0] = 0;
#ifdef DEBUG_TLS #ifdef DEBUG_TLS
printf("Client TLS [TLS version len: %u]\n", version_len); printf("Client TLS [TLS version len: %u]\n", version_len);
+2 -1
View File
@@ -55,7 +55,8 @@ void ndpi_search_ubntac2(struct ndpi_detection_module_struct *ndpi_struct, struc
if(found < packet->payload_packet_len) { if(found < packet->payload_packet_len) {
char version[256]; char version[256];
int i, j, len; int len;
u_int i, j;
for(i=found, j=0; (i < packet->payload_packet_len) for(i=found, j=0; (i < packet->payload_packet_len)
&& (i < (sizeof(version)-1)) && (i < (sizeof(version)-1))
+1 -1
View File
@@ -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) { int ac_automata_exact_match(AC_PATTERNS_t *mp,int pos, AC_TEXT_t *txt) {
AC_PATTERN_t *patterns = mp->patterns; AC_PATTERN_t *patterns = mp->patterns;
AC_PATTERN_t **matched = txt->match.matched; AC_PATTERN_t **matched = txt->match.matched;
int i; unsigned int i;
int match_map = 0; int match_map = 0;
for(i=0; i < mp->num && i < ((sizeof(int)*8)-1); i++,patterns++) { for(i=0; i < mp->num && i < ((sizeof(int)*8)-1); i++,patterns++) {
do { do {
+1 -1
View File
@@ -300,7 +300,7 @@ cache_result cache_remove(cache_t cache, void *item, uint32_t item_size) {
} }
void cache_free(cache_t cache) { void cache_free(cache_t cache) {
int i; uint32_t i;
if(!cache) { if(!cache) {
return; return;
} }
+1 -1
View File
@@ -68,7 +68,7 @@ int serializerUnitTest() {
#ifdef HAVE_JSON_H #ifdef HAVE_JSON_H
ndpi_serializer serializer, deserializer; ndpi_serializer serializer, deserializer;
int i, loop_id; int i, loop_id;
ndpi_serialization_format fmt; ndpi_serialization_format fmt = {0};
u_int32_t buffer_len; u_int32_t buffer_len;
char *buffer; char *buffer;
enum json_tokener_error jerr; enum json_tokener_error jerr;