What version of Go are you using (go version)?
$ go version
go version go1.15.5 linux/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
GOOS=linux
GOARCH=amd64
What did you do?
Called the (*os.File).ReadAt method with a 2-byte destination slice.
What did you expect to see?
Data in the destination slice and no error or panic.
What did you see instead?
panic: runtime error: slice bounds out of range [4:2]
goroutine 63 [running]:
os.(*File).ReadAt(...)
/usr/local/go/src/os/file.go:140 +0x3e5
The panic corresponds with the source line b = b[m:].
Before re-slicing the destination buffer, a bounds-check is needed. Apparently, it's possible for lower layers to return more than the requested number of bytes within the initial read.
What version of Go are you using (
go version)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env)?GOOS=linux
GOARCH=amd64
What did you do?
Called the
(*os.File).ReadAtmethod with a 2-byte destination slice.What did you expect to see?
Data in the destination slice and no error or panic.
What did you see instead?
The panic corresponds with the source line
b = b[m:].Before re-slicing the destination buffer, a bounds-check is needed. Apparently, it's possible for lower layers to return more than the requested number of bytes within the initial read.