debug/pe: should check return of r.ReadAt at NewFile

Change-Id: I7092c180ec05d472d723c2a40498476445551c93
GitHub-Last-Rev: 46286c5cad
GitHub-Pull-Request: golang/go#78961
Reviewed-on: https://go-review.googlesource.com/c/go/+/770741
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Sean Liao <sean@liao.dev>
This commit is contained in:
Weixie Cui 2026-04-25 09:34:21 +00:00 committed by Gopher Robot
parent 3fdac6780b
commit c5b875218f

View file

@ -81,7 +81,9 @@ func NewFile(r io.ReaderAt) (*File, error) {
if dosheader[0] == 'M' && dosheader[1] == 'Z' {
signoff := int64(binary.LittleEndian.Uint32(dosheader[0x3c:]))
var sign [4]byte
r.ReadAt(sign[:], signoff)
if _, err := r.ReadAt(sign[:], signoff); err != nil {
return nil, err
}
if !(sign[0] == 'P' && sign[1] == 'E' && sign[2] == 0 && sign[3] == 0) {
return nil, fmt.Errorf("invalid PE file signature: % x", sign)
}