aboutsummaryrefslogtreecommitdiff
path: root/src/lib/ndpi_utils.c
diff options
context:
space:
mode:
authorToni <matzeton@googlemail.com>2022-06-03 18:21:29 +0200
committerGitHub <noreply@github.com>2022-06-03 18:21:29 +0200
commit09fbe0a64a11b08a35435f516e9a19f7e0c20d7c (patch)
tree3a1f16a822cd21e52da4b9e56486906cb104bb62 /src/lib/ndpi_utils.c
parent6149c0f880163b0bebd513fa957ece325c77cb88 (diff)
Fixed syslog false positives. (#1577)
* syslog: removed unnecessary/unreliable printable string check * added `ndpi_isalnum()` * splitted `ndpi_is_printable_string()` into `ndpi_is_printable_buffer()` and `ndpi_normalize_printable_string()` Signed-off-by: lns <matzeton@googlemail.com>
Diffstat (limited to 'src/lib/ndpi_utils.c')
-rw-r--r--src/lib/ndpi_utils.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/lib/ndpi_utils.c b/src/lib/ndpi_utils.c
index 4d7aedca3..f2cb9a4d5 100644
--- a/src/lib/ndpi_utils.c
+++ b/src/lib/ndpi_utils.c
@@ -755,8 +755,8 @@ static int _ndpi_is_valid_char(char c) {
if(ispunct(c) && (!ndpi_is_other_char(c)))
return(0);
else
- return(isdigit(c)
- || isalpha(c)
+ return(ndpi_isdigit(c)
+ || ndpi_isalpha(c)
|| ndpi_is_other_char(c));
}
static char ndpi_is_valid_char_tbl[256],ndpi_is_valid_char_tbl_init=0;
@@ -2274,7 +2274,22 @@ int ndpi_isset_risk(struct ndpi_detection_module_struct *ndpi_str,
/* ******************************************************************** */
-int ndpi_is_printable_string(char * const str, size_t len) {
+int ndpi_is_printable_buffer(uint8_t const * const buf, size_t len) {
+ int retval = 1;
+ size_t i;
+
+ for(i = 0; i < len; ++i) {
+ if(ndpi_isprint(buf[i]) == 0) {
+ retval = 0;
+ }
+ }
+
+ return retval;
+}
+
+/* ******************************************************************** */
+
+int ndpi_normalize_printable_string(char * const str, size_t len) {
int retval = 1;
size_t i;