aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorIvan Nardi <12729895+IvanNardi@users.noreply.github.com>2025-05-25 17:49:52 +0200
committerGitHub <noreply@github.com>2025-05-25 17:49:52 +0200
commit46dff3474e5c6df46ed2dafc476070fc2e3076f6 (patch)
tree7b6035f003653d51b0f4746e69990a814d487508 /src/lib
parentb1f0c6ceb5f1bb81b404d26f071dc78a2f23ffdd (diff)
Fix some warnings reported by scan-build (#2851)
Close #2807
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/ndpi_domain_classify.c3
-rw-r--r--src/lib/ndpi_domains.c7
-rw-r--r--src/lib/ndpi_serializer.c4
-rw-r--r--src/lib/protocols/dns.c5
-rw-r--r--src/lib/protocols/memcached.c2
-rw-r--r--src/lib/protocols/ssh.c1
6 files changed, 10 insertions, 12 deletions
diff --git a/src/lib/ndpi_domain_classify.c b/src/lib/ndpi_domain_classify.c
index 53de06e54..5b9457006 100644
--- a/src/lib/ndpi_domain_classify.c
+++ b/src/lib/ndpi_domain_classify.c
@@ -150,7 +150,6 @@ bool ndpi_domain_classify_hostname(struct ndpi_detection_module_struct *ndpi_mod
ndpi_domain_classify *s,
u_int16_t *class_id /* out */,
char *hostname) {
- u_int32_t len;
const char *dot;
char *item;
@@ -159,7 +158,7 @@ bool ndpi_domain_classify_hostname(struct ndpi_detection_module_struct *ndpi_mod
*class_id = 0; /* Unknown class_id */
if(!hostname || !s) return(false);
- if((len = strlen(hostname)) == 0) return(false);
+ if(strlen(hostname) == 0) return(false);
if((dot = strrchr(hostname, '.')) == NULL) return(false);
if((!strcmp(dot, ".arpa")) || (!strcmp(dot, ".local"))) return(false);
diff --git a/src/lib/ndpi_domains.c b/src/lib/ndpi_domains.c
index 52ee66417..81a1428eb 100644
--- a/src/lib/ndpi_domains.c
+++ b/src/lib/ndpi_domains.c
@@ -38,12 +38,15 @@ int ndpi_load_domain_suffixes(struct ndpi_detection_module_struct *ndpi_str,
return(-2);
if(ndpi_str->public_domain_suffixes != NULL) {
- /* An existing license was aleady loaded: free it and start over */
+ /* An existing license was already loaded: free it and start over */
+ fclose(fd);
ndpi_hash_free(&ndpi_str->public_domain_suffixes);
}
- if(ndpi_hash_init(&ndpi_str->public_domain_suffixes) != 0)
+ if(ndpi_hash_init(&ndpi_str->public_domain_suffixes) != 0) {
+ fclose(fd);
return(-3);
+ }
while((line = fgets(buf, sizeof(buf), fd)) != NULL) {
u_int offset, len;
diff --git a/src/lib/ndpi_serializer.c b/src/lib/ndpi_serializer.c
index 1510d470d..dfec1620e 100644
--- a/src/lib/ndpi_serializer.c
+++ b/src/lib/ndpi_serializer.c
@@ -3041,9 +3041,9 @@ int ndpi_deserialize_clone_item(ndpi_deserializer *_deserializer, ndpi_serialize
/* Clone all elements in deserializer to serializer (this can be used to convert a TLV record to JSON) */
int ndpi_deserialize_clone_all(ndpi_deserializer *deserializer, ndpi_serializer *serializer) {
ndpi_serialization_type kt, et;
- u_int32_t u32, k32;
+ u_int32_t u32, k32 = 0;
int32_t i32;
- u_int64_t u64;
+ u_int64_t u64 = 0;
int64_t i64;
float f;
ndpi_string vs, ks;
diff --git a/src/lib/protocols/dns.c b/src/lib/protocols/dns.c
index e75449fe4..0e5855016 100644
--- a/src/lib/protocols/dns.c
+++ b/src/lib/protocols/dns.c
@@ -628,12 +628,11 @@ static int is_valid_dns(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_dns_packet_header *dns_header,
u_int payload_offset, u_int8_t *is_query) {
struct ndpi_packet_struct *packet = &ndpi_struct->packet;
- u_int x = payload_offset;
if(packet->payload_packet_len < sizeof(struct ndpi_dns_packet_header) + payload_offset)
return 0;
- memcpy(dns_header, (struct ndpi_dns_packet_header*)&packet->payload[x],
+ memcpy(dns_header, (struct ndpi_dns_packet_header*)&packet->payload[payload_offset],
sizeof(struct ndpi_dns_packet_header));
dns_header->tr_id = ntohs(dns_header->tr_id);
@@ -643,8 +642,6 @@ static int is_valid_dns(struct ndpi_detection_module_struct *ndpi_struct,
dns_header->authority_rrs = ntohs(dns_header->authority_rrs);
dns_header->additional_rrs = ntohs(dns_header->additional_rrs);
- x += sizeof(struct ndpi_dns_packet_header);
-
if((dns_header->flags & FLAGS_MASK) == 0x0000)
*is_query = 1;
else
diff --git a/src/lib/protocols/memcached.c b/src/lib/protocols/memcached.c
index fcabbd0f7..9fc477bae 100644
--- a/src/lib/protocols/memcached.c
+++ b/src/lib/protocols/memcached.c
@@ -118,7 +118,7 @@ static void ndpi_search_memcached(struct ndpi_detection_module_struct *ndpi_stru
matches = &flow->l4.tcp.memcached_matches;
}
- else if (packet->udp != NULL) {
+ else {
if (packet->payload_packet_len < MEMCACHED_MIN_UDP_LEN) {
NDPI_EXCLUDE_DISSECTOR(ndpi_struct, flow);
return;
diff --git a/src/lib/protocols/ssh.c b/src/lib/protocols/ssh.c
index 56812117e..6058a661d 100644
--- a/src/lib/protocols/ssh.c
+++ b/src/lib/protocols/ssh.c
@@ -362,7 +362,6 @@ static u_int16_t concat_hash_string(struct ndpi_detection_module_struct *ndpi_st
if(len > len_max)
goto invalid_payload;
- offset += len;
/* ssh.languages_client_to_server [None] */