From: Jason Ish Date: Fri, 4 Sep 2020 16:45:52 +0000 (-0600) Subject: rule parsing: valid that input rule string is UTF8 X-Git-Tag: suricata-6.0.0-rc1~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cc2c7b731a93c5f6480a98a0739c4298c5627512;p=thirdparty%2Fsuricata.git rule parsing: valid that input rule string is UTF8 Before parsing a rule string, validate that it is UTF-8 first. Related Redmine issue: https://redmine.openinfosecfoundation.org/issues/3850 --- diff --git a/src/detect-parse.c b/src/detect-parse.c index b9962dbf40..b7b1e5980f 100644 --- a/src/detect-parse.c +++ b/src/detect-parse.c @@ -1212,6 +1212,11 @@ static int SigParse(DetectEngineCtx *de_ctx, Signature *s, { SCEnter(); + if (!rs_check_utf8(sigstr)) { + SCLogError(SC_ERR_RULE_INVALID_UTF8, "rule is not valid UTF-8"); + SCReturnInt(-1); + } + s->sig_str = SCStrdup(sigstr); if (unlikely(s->sig_str == NULL)) { SCReturnInt(-1); diff --git a/src/util-error.c b/src/util-error.c index 0a5496767f..64b4555c33 100644 --- a/src/util-error.c +++ b/src/util-error.c @@ -376,6 +376,7 @@ const char * SCErrorToString(SCError err) CASE_CODE (SC_WARN_PATH_READ_ERROR); CASE_CODE (SC_ERR_PLUGIN); CASE_CODE(SC_ERR_LOG_OUTPUT); + CASE_CODE(SC_ERR_RULE_INVALID_UTF8); CASE_CODE (SC_ERR_MAX); } diff --git a/src/util-error.h b/src/util-error.h index 3a78ae9df5..54b320a07c 100644 --- a/src/util-error.h +++ b/src/util-error.h @@ -366,6 +366,7 @@ typedef enum { SC_ERR_HTTP2_LOG_GENERIC, SC_ERR_PLUGIN, SC_ERR_LOG_OUTPUT, + SC_ERR_RULE_INVALID_UTF8, SC_ERR_MAX } SCError;