From dd8953cb6452f0dc174063715aabe59abd388659 Mon Sep 17 00:00:00 2001 From: Luca Date: Thu, 14 Jul 2022 18:13:42 +0200 Subject: [PATCH] Added pointer checks Added -O2 (lost in release) --- configure.ac | 2 +- src/lib/ndpi_utils.c | 44 +++++++++++++++++++++++++------------------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/configure.ac b/configure.ac index c9bb5d74f..25638e860 100644 --- a/configure.ac +++ b/configure.ac @@ -31,7 +31,7 @@ AS_IF([test "${with_sanitizer+set}" = set -a "${with_thread_sanitizer+set}" = se AS_IF([test "${with_sanitizer+set}" = set -o "${with_thread_sanitizer+set}" = set],[ CFLAGS="${CFLAGS} -O0 -g3" ],[ - CFLAGS="${CFLAGS} -g" + CFLAGS="${CFLAGS} -O2" ]) AS_IF([test "${with_sanitizer+set}" = set],[ diff --git a/src/lib/ndpi_utils.c b/src/lib/ndpi_utils.c index 15b71caf1..3aad97332 100644 --- a/src/lib/ndpi_utils.c +++ b/src/lib/ndpi_utils.c @@ -2182,16 +2182,18 @@ static u_int64_t ndpi_host_ip_risk_ptree_match(struct ndpi_detection_module_stru /* Check isuerDN exception */ u_int8_t ndpi_check_issuerdn_risk_exception(struct ndpi_detection_module_struct *ndpi_str, char *issuerDN) { - ndpi_list *head = ndpi_str->trusted_issuer_dn; - + if(issuerDN != NULL) { + ndpi_list *head = ndpi_str->trusted_issuer_dn; + while(head != NULL) { if(strcmp(issuerDN, head->value) == 0) return(1); /* This is a trusted DN */ else head = head->next; + } } - return(0 /* no exception */); + return(0 /* no exception */); } /* ********************************************************************************* */ @@ -2200,23 +2202,27 @@ u_int8_t ndpi_check_issuerdn_risk_exception(struct ndpi_detection_module_struct static u_int8_t ndpi_check_hostname_risk_exception(struct ndpi_detection_module_struct *ndpi_str, struct ndpi_flow_struct *flow, char *hostname) { - ndpi_automa *automa = &ndpi_str->host_risk_mask_automa; - u_int8_t ret = 0; - - if(automa->ac_automa) { - AC_TEXT_t ac_input_text; - AC_REP_t match; - - ac_input_text.astring = hostname, ac_input_text.length = strlen(hostname); - ac_input_text.option = 0; - - if(ac_automata_search(automa->ac_automa, &ac_input_text, &match) > 0) { - if(flow) flow->risk_mask &= match.number64; - ret = 1; - } + if(hostname == NULL) + return(0); + else { + ndpi_automa *automa = &ndpi_str->host_risk_mask_automa; + u_int8_t ret = 0; + + if(automa->ac_automa) { + AC_TEXT_t ac_input_text; + AC_REP_t match; + + ac_input_text.astring = hostname, ac_input_text.length = strlen(hostname); + ac_input_text.option = 0; + + if(ac_automata_search(automa->ac_automa, &ac_input_text, &match) > 0) { + if(flow) flow->risk_mask &= match.number64; + ret = 1; + } + } + + return(ret); } - - return(ret); } /* ********************************************************************************* */