From: Ian Lance Taylor Date: Tue, 21 Feb 2023 18:14:20 +0000 (-0800) Subject: debug/macho: use saferio to read symbol table strings X-Git-Tag: go1.21rc1~1525 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=ed33ae10a011c85f51be2c970f52d769722b0ec7;p=gostls13.git debug/macho: use saferio to read symbol table strings No test case because the problem can only happen for invalid data. Let the fuzzer find cases like this. For #47653 Fixes #58603 Change-Id: I67fc45365c1a5b0b4b381f541bf2fee8ce8ddc3a Reviewed-on: https://go-review.googlesource.com/c/go/+/469895 TryBot-Result: Gopher Robot Run-TryBot: Ian Lance Taylor Reviewed-by: Bryan Mills Auto-Submit: Ian Lance Taylor Reviewed-by: Ian Lance Taylor Run-TryBot: Ian Lance Taylor --- diff --git a/src/debug/macho/file.go b/src/debug/macho/file.go index ecde25ab89..9806c270bf 100644 --- a/src/debug/macho/file.go +++ b/src/debug/macho/file.go @@ -323,8 +323,8 @@ func NewFile(r io.ReaderAt) (*File, error) { if err := binary.Read(b, bo, &hdr); err != nil { return nil, err } - strtab := make([]byte, hdr.Strsize) - if _, err := r.ReadAt(strtab, int64(hdr.Stroff)); err != nil { + strtab, err := saferio.ReadDataAt(r, uint64(hdr.Strsize), int64(hdr.Stroff)) + if err != nil { return nil, err } var symsz int