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;