Skip to content

Commit 3b37734

Browse files
committed
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.
1 parent 314ea0c commit 3b37734

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

pkg/ast/scanner.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ func (s *scanner) next() {
279279
// Makes lots of things simpler as we always
280280
// want to treat EOF as NEWLINE as well.
281281
s.ch = '\n'
282-
s.off++
283282
return
284283
}
285284
if s.off > len(s.data) {

pkg/compiler/compiler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ type D[e]l`,
202202
"E",
203203
"#",
204204
} {
205-
Fuzz([]byte(data))
205+
Fuzz([]byte(data)[:len(data):len(data)])
206206
}
207207
}
208208

0 commit comments

Comments
 (0)