From 39b1d49fc363e34e78d17afddb6c5cc3625ae42a Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Tue, 15 Jan 2019 14:24:55 -0600 Subject: [PATCH] GH-170: fix segfault triggered by invalid pattern symbols Fixes GH-170 --- CHANGES | 4 ++++ VERSION | 2 +- src/re-parse.y | 13 ++++++++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 74c7b9a19f..6f89b8d31e 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,8 @@ +2.6-77 | 2019-01-15 14:24:55 -0600 + + * GH-170: fix segfault triggered by invalid pattern symbols (Jon Siwek, Corelight) + 2.6-76 | 2019-01-15 12:12:09 -0600 * GH-172: fix broxygen not merging bif and script identifier comments (Jon Siwek, Corelight) diff --git a/VERSION b/VERSION index 391b67856f..d779f10045 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.6-76 +2.6-77 diff --git a/src/re-parse.y b/src/re-parse.y index 95573f6a22..164705c040 100644 --- a/src/re-parse.y +++ b/src/re-parse.y @@ -131,7 +131,18 @@ singleton : singleton '*' { $$ = $2; case_insensitive = 0; } | TOK_CHAR - { $$ = new NFA_Machine(new NFA_State($1, rem->EC())); } + { + auto sym = $1; + + if ( sym < 0 || ( sym >= NUM_SYM && sym != SYM_EPSILON ) ) + { + reporter->Error("bad symbol %d (compiling pattern /%s/)", sym, + RE_parse_input); + return 1; + } + + $$ = new NFA_Machine(new NFA_State(sym, rem->EC())); + } | '^' {