aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/ndpi_main.c13
-rw-r--r--src/lib/protocols/coap.c2
-rw-r--r--src/lib/protocols/mdns_proto.c2
-rw-r--r--src/lib/protocols/ssl.c2
4 files changed, 10 insertions, 9 deletions
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c
index 863943c4a..ad7c788ac 100644
--- a/src/lib/ndpi_main.c
+++ b/src/lib/ndpi_main.c
@@ -842,21 +842,21 @@ static int init_hyperscan(struct ndpi_detection_module_struct *ndpi_mod) {
}
need_to_be_free = (unsigned char*)calloc(sizeof(unsigned char), num_patterns + 1);
- if (!need_to_be_free) {
+ if(!need_to_be_free) {
free(expressions);
free(ids);
return(-1);
}
- for (i = 0, j = 0; host_match[i].string_to_match != NULL || host_match[i].pattern_to_match != NULL; i++) {
- if (host_match[i].pattern_to_match) {
+ for(i = 0, j = 0; host_match[i].string_to_match != NULL || host_match[i].pattern_to_match != NULL; i++) {
+ if(host_match[i].pattern_to_match) {
expressions[j] = host_match[i].pattern_to_match;
ids[j] = host_match[i].protocol_id;
need_to_be_free[j] = 0;
++j;
} else {
expressions[j] = string2hex(host_match[i].string_to_match);
- if (expressions[j] != NULL) {
+ if(expressions[j] != NULL) {
ids[j] = host_match[i].protocol_id;
need_to_be_free[j] = 1;
++j;
@@ -871,11 +871,12 @@ static int init_hyperscan(struct ndpi_detection_module_struct *ndpi_mod) {
rc = hyperscan_load_patterns(hs, j, (const char**)expressions, ids);
- for (i = 0; i < j; ++i)
- if (need_to_be_free[i])
+ for(i = 0; i < j; ++i)
+ if(need_to_be_free[i])
free(expressions[i]);
free(expressions), free(ids);
+ free(need_to_be_free);
return(rc);
}
diff --git a/src/lib/protocols/coap.c b/src/lib/protocols/coap.c
index 5ac8cb80e..cf5061bbe 100644
--- a/src/lib/protocols/coap.c
+++ b/src/lib/protocols/coap.c
@@ -129,7 +129,7 @@ void ndpi_search_coap (struct ndpi_detection_module_struct *ndpi_struct,
// check values in header
if(h->version == 1) {
if(h->type == CON || h->type == NO_CON || h->type == ACK || h->type == RST ) {
- if(h->tkl == 0 || h->tkl < 8) {
+ if(h->tkl < 8) {
if((h->code >= 0 && h->code <= 5) || (h->code >= 65 && h->code <= 69) ||
(h->code >= 128 && h->code <= 134) || (h->code >= 140 && h->code <= 143) ||
(h->code >= 160 && h->code <= 165)) {
diff --git a/src/lib/protocols/mdns_proto.c b/src/lib/protocols/mdns_proto.c
index 77bdf4208..00c7c8748 100644
--- a/src/lib/protocols/mdns_proto.c
+++ b/src/lib/protocols/mdns_proto.c
@@ -77,7 +77,7 @@ static int ndpi_int_check_mdns_payload(struct ndpi_detection_module_struct
char answer[256];
int i, j, len;
- for(i=13, j=0; (packet->payload[i] != 0) && (i < packet->payload_packet_len) && (i < (sizeof(answer)-1)); i++)
+ for(i=13, j=0; (i < packet->payload_packet_len) && (i < (sizeof(answer)-1)) && (packet->payload[i] != 0); i++)
answer[j++] = (packet->payload[i] < 13) ? '.' : packet->payload[i];
answer[j] = '\0';
diff --git a/src/lib/protocols/ssl.c b/src/lib/protocols/ssl.c
index 25d535a57..4651b358f 100644
--- a/src/lib/protocols/ssl.c
+++ b/src/lib/protocols/ssl.c
@@ -559,7 +559,7 @@ static u_int8_t ndpi_search_sslv3_direction1(struct ndpi_detection_module_struct
}
}
- if((packet->payload_packet_len > temp && packet->payload_packet_len > 100) && packet->payload_packet_len > 9) {
+ if((packet->payload_packet_len > temp) && (packet->payload_packet_len > 100)) {
/* the server hello may be split into small packets and the certificate has its own SSL Record
* so temp contains only the length for the first ServerHello block */
u_int32_t cert_start;