mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
[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:
@@ -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
|
||||
}
|
||||
|
||||
@@ -385,9 +385,11 @@ func TestIncludeVariablesWithChecks(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestParserNoInfiniteLoop(t *testing.T) {
|
||||
if _, err := Parse(`A@@Føøøø?˛ø:{øøøø˙˙`); err == nil {
|
||||
t.Fatal("expected an error")
|
||||
} else if !strings.Contains(err.Error(), "Unexpected EOF") {
|
||||
t.Fatal("expected unexpected eof error")
|
||||
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")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user