diff options
author | Luca Deri <deri@ntop.org> | 2022-05-30 00:54:17 +0200 |
---|---|---|
committer | Luca Deri <deri@ntop.org> | 2022-05-30 00:54:17 +0200 |
commit | 1da9f1a36fc2f60d8a2f13fca88a7675d327e3ad (patch) | |
tree | a31d58df13a16aa3f651a61186a32e7f5fa1f1e7 /src | |
parent | f25deeccb1ccbebd6346271828762fdd8326c32b (diff) |
Updated tests results
Code cleanup
Diffstat (limited to 'src')
-rw-r--r-- | src/include/ndpi_api.h.in | 3 | ||||
-rw-r--r-- | src/lib/ndpi_utils.c | 29 | ||||
-rw-r--r-- | src/lib/protocols/http.c | 2 | ||||
-rw-r--r-- | src/lib/protocols/quic.c | 2 | ||||
-rw-r--r-- | src/lib/protocols/tls.c | 4 |
5 files changed, 22 insertions, 18 deletions
diff --git a/src/include/ndpi_api.h.in b/src/include/ndpi_api.h.in index c350159f0..01c55b9d0 100644 --- a/src/include/ndpi_api.h.in +++ b/src/include/ndpi_api.h.in @@ -1735,6 +1735,9 @@ extern "C" { /* ******************************* */ + char* ndpi_get_flow_risk_info(struct ndpi_flow_struct *flow, + char *out, u_int out_len); + #ifdef __cplusplus } #endif diff --git a/src/lib/ndpi_utils.c b/src/lib/ndpi_utils.c index 6d832115b..3f98ef0a7 100644 --- a/src/lib/ndpi_utils.c +++ b/src/lib/ndpi_utils.c @@ -2524,24 +2524,25 @@ int ndpi_snprintf(char * str, size_t size, char const * format, ...) { char* ndpi_get_flow_risk_info(struct ndpi_flow_struct *flow, char *out, u_int out_len) { - if(out == NULL) + u_int i, offset = 0; + + if((out == NULL) || (flow->num_risk_infos == 0)) return(NULL); - else - out[0] = '\0'; + + out[0] = '\0'; - if(flow->num_risk_infos) { - u_int i, offset = 0; - for(i=0; i<flow->num_risk_infos; i++) { - int rc = snprintf(&out[offset], out_len-offset, "%s%s", - (i == 0) ? "" : " / ", - flow->risk_infos[i]); + for(i=0; i<flow->num_risk_infos; i++) { + int rc = snprintf(&out[offset], out_len-offset, "%s%s", + (i == 0) ? "" : " / ", + flow->risk_infos[i]); - if(rc <= 0) - break; - else - offset += rc; - } + if(rc <= 0) + break; + else + offset += rc; } + out[offset] = '\0'; + return(out[0] == '\0' ? NULL : out); } diff --git a/src/lib/protocols/http.c b/src/lib/protocols/http.c index 4788a4e52..9f1dd9cf5 100644 --- a/src/lib/protocols/http.c +++ b/src/lib/protocols/http.c @@ -715,7 +715,7 @@ static void check_content_type_and_change_protocol(struct ndpi_detection_module_ if(ndpi_is_valid_hostname(flow->host_server_name, strlen(flow->host_server_name)) == 0) { - char str[64]; + char str[128]; snprintf(str, sizeof(str), "Invalid host %s", flow->host_server_name); ndpi_set_risk(ndpi_struct, flow, NDPI_INVALID_CHARACTERS, str); diff --git a/src/lib/protocols/quic.c b/src/lib/protocols/quic.c index 0f1d37a70..61e7f6880 100644 --- a/src/lib/protocols/quic.c +++ b/src/lib/protocols/quic.c @@ -1395,7 +1395,7 @@ static void process_chlo(struct ndpi_detection_module_struct *ndpi_struct, if(ndpi_is_valid_hostname(flow->host_server_name, strlen(flow->host_server_name)) == 0) { - char str[64]; + char str[128]; snprintf(str, sizeof(str), "Invalid host %s", flow->host_server_name); ndpi_set_risk(ndpi_struct, flow, NDPI_INVALID_CHARACTERS, str); diff --git a/src/lib/protocols/tls.c b/src/lib/protocols/tls.c index aef6ede7e..24ed7b20e 100644 --- a/src/lib/protocols/tls.c +++ b/src/lib/protocols/tls.c @@ -478,7 +478,7 @@ static void processCertificateElements(struct ndpi_detection_module_struct *ndpi } if((time_sec < flow->protos.tls_quic.notBefore) || (time_sec > flow->protos.tls_quic.notAfter)) { - char str[64], b[32], e[32]; + char str[96], b[32], e[32]; struct tm result; time_t theTime; @@ -492,7 +492,7 @@ static void processCertificateElements(struct ndpi_detection_module_struct *ndpi ndpi_set_risk(ndpi_struct, flow, NDPI_TLS_CERTIFICATE_EXPIRED, str); /* Certificate expired */ } else if((time_sec > flow->protos.tls_quic.notBefore) && (time_sec > (flow->protos.tls_quic.notAfter - (ndpi_struct->tls_certificate_expire_in_x_days * 86400)))) { - char str[64], b[32], e[32]; + char str[96], b[32], e[32]; struct tm result; time_t theTime; |