From 32b5a16d97251d16df404f440c78a7d79f63d2f1 Mon Sep 17 00:00:00 2001 From: Matthias Hanel Date: Tue, 5 Jan 2021 18:25:41 -0500 Subject: [PATCH] [fixed] two minor configuration lexer issues found by oss-fuzz after eof isVariable had a buffer overflow stringStateFn was not set when lexString was returned Signed-off-by: Matthias Hanel --- conf/lex.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/conf/lex.go b/conf/lex.go index 9358c9b3..8d36262a 100644 --- a/conf/lex.go +++ b/conf/lex.go @@ -783,6 +783,9 @@ func (lx *lexer) isBool() bool { // Check if the unquoted string is a variable reference, starting with $. func (lx *lexer) isVariable() bool { + if lx.start >= len(lx.input) { + return false + } if lx.input[lx.start] == '$' { lx.start += 1 return true @@ -984,6 +987,7 @@ func lexNumberOrDateOrStringOrIP(lx *lexer) stateFn { case !(isNL(r) || r == eof || r == mapEnd || r == optValTerm || r == mapValTerm || isWhitespace(r) || unicode.IsDigit(r)): // Treat it as a string value once we get a rune that // is not a number. + lx.stringStateFn = lexString return lexString } lx.backup()