aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Deri <deri@ntop.org>2023-09-05 18:08:16 +0200
committerLuca Deri <deri@ntop.org>2023-09-05 18:08:16 +0200
commitad9ed4f95480d6cd093ee259d520cf802fec7ed2 (patch)
tree0bebb2e8957098d8248073debf8d16394a68aceb
parent978df906b38c26a359b2d91089e70e133cc7502e (diff)
Minor warning fixes
-rw-r--r--configure.ac6
-rw-r--r--src/lib/ndpi_domain_classify.c11
-rw-r--r--src/lib/ndpi_utils.c4
-rw-r--r--src/lib/protocols/ssh.c11
4 files changed, 24 insertions, 8 deletions
diff --git a/configure.ac b/configure.ac
index 545a8b4e1..8bbad3917 100644
--- a/configure.ac
+++ b/configure.ac
@@ -19,6 +19,7 @@ PWD=`pwd`
AC_ARG_WITH(sanitizer, AS_HELP_STRING([--with-sanitizer], [Build with support for address, undefined and leak sanitizer]))
AC_ARG_WITH(thread-sanitizer, AS_HELP_STRING([--with-thread-sanitizer], [Build with support for thread sanitizer]))
AC_ARG_WITH(memory-sanitizer, AS_HELP_STRING([--with-memory-sanitizer], [Build with support for memory sanitizer]))
+AC_ARG_WITH(macos-memory-sanitizer, AS_HELP_STRING([--with-macos-memory-sanitizer], [Build with support for memory sanitizer macOS]))
AC_ARG_ENABLE(fuzztargets, AS_HELP_STRING([--enable-fuzztargets], [Enable fuzz targets]),[enable_fuzztargets=$enableval],[enable_fuzztargets=no])
AC_ARG_ENABLE(gprof, AS_HELP_STRING([--enable-gprof], [Enable CPU/HEAP profiling with gperftools]),[enable_gprof=$enableval],[enable_gprof=no])
AC_ARG_ENABLE(code-coverage, AS_HELP_STRING([--enable-code-coverage], [Generate Code Coverage report]))
@@ -77,6 +78,11 @@ AS_IF([test "${with_memory_sanitizer+set}" = set],[
NDPI_LDFLAGS="${NDPI_LDFLAGS} -fsanitize=memory"
])
+AS_IF([test "${with_macos_memory_sanitizer+set}" = set],[
+ NDPI_CFLAGS="${NDPI_CFLAGS} -fsanitize=address -fno-omit-frame-pointer -fsanitize=signed-integer-overflow -fno-sanitize-recover=address"
+ NDPI_LDFLAGS="${NDPI_LDFLAGS} -fsanitize=address"
+])
+
AS_IF([test "x${enable_code_coverage}" = "xyes"],[
NDPI_CFLAGS="${NDPI_CFLAGS} -fprofile-arcs -ftest-coverage"
NDPI_LDFLAGS="${NDPI_LDFLAGS} --coverage"
diff --git a/src/lib/ndpi_domain_classify.c b/src/lib/ndpi_domain_classify.c
index 2b2e5b6f6..0c9979922 100644
--- a/src/lib/ndpi_domain_classify.c
+++ b/src/lib/ndpi_domain_classify.c
@@ -128,7 +128,8 @@ u_int32_t ndpi_domain_classify_add_domains(ndpi_domain_classify *s,
while((line = fgets(buf, sizeof(buf), fd)) != NULL) {
u_int len;
-
+ u_int64_t hash;
+
if((line[0] == '#') || (line[0] == '\0'))
continue;
else {
@@ -140,8 +141,9 @@ u_int32_t ndpi_domain_classify_add_domains(ndpi_domain_classify *s,
line[len] = '\0';
}
- if(ndpi_bitmap64_set(s->classes[i].domains,
- ndpi_quick_hash64(line, strlen(line))))
+ hash = ndpi_quick_hash64(line, strlen(line));
+
+ if(ndpi_bitmap64_set(s->classes[i].domains, hash))
num_added++;
}
@@ -170,7 +172,6 @@ bool ndpi_domain_classify_contains(ndpi_domain_classify *s,
u_int8_t *class_id /* out */,
char *domain) {
u_int32_t i, len;
- u_int64_t hash;
char *dot, *elem;
if(!domain) return(false);
@@ -198,7 +199,7 @@ bool ndpi_domain_classify_contains(ndpi_domain_classify *s,
elem = domain;
while(elem != NULL) {
- hash = ndpi_quick_hash64(elem, strlen(elem));
+ u_int64_t hash = ndpi_quick_hash64(elem, strlen(elem));
for(i=0; i<MAX_NUM_NDPI_DOMAIN_CLASSIFICATIONS; i++) {
if(s->classes[i].class_id != 0) {
diff --git a/src/lib/ndpi_utils.c b/src/lib/ndpi_utils.c
index b58fce522..854b548f0 100644
--- a/src/lib/ndpi_utils.c
+++ b/src/lib/ndpi_utils.c
@@ -1274,7 +1274,9 @@ int ndpi_dpi2json(struct ndpi_detection_module_struct *ndpi_struct,
char bittorent_hash[sizeof(flow->protos.bittorrent.hash)*2+1];
for(i=0, j = 0; j < sizeof(bittorent_hash)-1; i++) {
- sprintf(&bittorent_hash[j], "%02x",
+ snprintf(&bittorent_hash[j],
+ sizeof(bittorent_hash) - j,
+ "%02x",
flow->protos.bittorrent.hash[i]);
j += 2, n += flow->protos.bittorrent.hash[i];
diff --git a/src/lib/protocols/ssh.c b/src/lib/protocols/ssh.c
index 0ad010a10..5e65f1d82 100644
--- a/src/lib/protocols/ssh.c
+++ b/src/lib/protocols/ssh.c
@@ -481,7 +481,11 @@ static void ndpi_search_ssh_tcp(struct ndpi_detection_module_struct *ndpi_struct
printf("]\n");
}
#endif
- for(i=0; i<16; i++) sprintf(&flow->protos.ssh.hassh_client[i*2], "%02X", fingerprint_client[i] & 0xFF);
+ for(i=0; i<16; i++)
+ snprintf(&flow->protos.ssh.hassh_client[i*2],
+ sizeof(flow->protos.ssh.hassh_client) - (i*2),
+ "%02X", fingerprint_client[i] & 0xFF);
+
flow->protos.ssh.hassh_client[32] = '\0';
} else {
u_char fingerprint_server[16];
@@ -500,7 +504,10 @@ static void ndpi_search_ssh_tcp(struct ndpi_detection_module_struct *ndpi_struct
}
#endif
- for(i=0; i<16; i++) sprintf(&flow->protos.ssh.hassh_server[i*2], "%02X", fingerprint_server[i] & 0xFF);
+ for(i=0; i<16; i++)
+ snprintf(&flow->protos.ssh.hassh_server[i*2],
+ sizeof(flow->protos.ssh.hassh_server) - (i*2),
+ "%02X", fingerprint_server[i] & 0xFF);
flow->protos.ssh.hassh_server[32] = '\0';
}