Skip to content

Commit

Permalink
pkg/ast: fix out-of-bounds access
Browse files Browse the repository at this point in the history
Scanner can access data out of bounds on bad input.
Also fix regression fuzz test to be able to detect the bug.
  • Loading branch information
dvyukov committed Jul 30, 2019
1 parent 314ea0c commit 3b37734
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
1 change: 0 additions & 1 deletion pkg/ast/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ func (s *scanner) next() {
// Makes lots of things simpler as we always
// want to treat EOF as NEWLINE as well.
s.ch = '\n'
s.off++
return
}
if s.off > len(s.data) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/compiler/compiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ type D[e]l`,
"E",
"#",
} {
Fuzz([]byte(data))
Fuzz([]byte(data)[:len(data):len(data)])
}
}

Expand Down

0 comments on commit 3b37734

Please sign in to comment.