Skip to content

Commit

Permalink
syntax: fix another lexer error crash
Browse files Browse the repository at this point in the history
We had a couple of these "if err != nil { tok = EOF }", but we were
missing a third one in this last case. Found via fuzzing.
  • Loading branch information
mvdan committed Jan 25, 2018
1 parent 7f13687 commit 73411ab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions syntax/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ func (p *Parser) nextKeepSpaces() {
p.advanceLitOther(r)
}
}
if p.err != nil && p.tok != _EOF {
p.tok = _EOF
}
}

func (p *Parser) next() {
Expand Down
4 changes: 4 additions & 0 deletions syntax/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,10 @@ var shellTests = []errorCase{
in: "${a#\x80",
common: `1:5: invalid UTF-8 encoding`,
},
{
in: "${a-'\x80",
common: `1:6: invalid UTF-8 encoding`,
},
{
in: "echo $((a |\x80",
common: `1:12: invalid UTF-8 encoding`,
Expand Down

0 comments on commit 73411ab

Please sign in to comment.