[fiixed] infinite loop in config parser for include with quote and double quote

Signed-off-by: Matthias Hanel <mh@synadia.com>
This commit is contained in:
Matthias Hanel
2021-01-08 13:17:19 -05:00
parent c5c8e385ab
commit fc667aaafd
2 changed files with 10 additions and 4 deletions

View File

@@ -413,6 +413,8 @@ func lexIncludeQuotedString(lx *lexer) stateFn {
lx.next()
lx.ignore()
return lx.pop()
case r == eof:
return lx.errorf("Unexpected EOF in quoted include")
}
return lexIncludeQuotedString
}
@@ -429,6 +431,8 @@ func lexIncludeDubQuotedString(lx *lexer) stateFn {
lx.next()
lx.ignore()
return lx.pop()
case r == eof:
return lx.errorf("Unexpected EOF in double quoted include")
}
return lexIncludeDubQuotedString
}

View File

@@ -385,9 +385,11 @@ func TestIncludeVariablesWithChecks(t *testing.T) {
}
func TestParserNoInfiniteLoop(t *testing.T) {
if _, err := Parse(`A@@Føøøø?˛ø:{øøøø˙˙`); err == nil {
for _, test := range []string{`A@@Føøøø?˛ø:{øøøø˙˙`, `include "9/<2F>`} {
if _, err := Parse(test); err == nil {
t.Fatal("expected an error")
} else if !strings.Contains(err.Error(), "Unexpected EOF") {
t.Fatal("expected unexpected eof error")
}
}
}