pkg/ast: fix out-of-bounds access

Scanner can access data out of bounds on bad input.
Also fix regression fuzz test to be able to detect the bug.
This commit is contained in:
Dmitry Vyukov 2019-07-30 18:43:14 +02:00
parent 314ea0c952
commit 3b37734422
2 changed files with 1 additions and 2 deletions

View File

@ -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) {

View File

@ -202,7 +202,7 @@ type D[e]l`,
"E",
"#",
} {
Fuzz([]byte(data))
Fuzz([]byte(data)[:len(data):len(data)])
}
}