From: Ian Lance Taylor Date: Mon, 27 Feb 2023 23:52:52 +0000 (-0800) Subject: debug/macho: use saferio to read dynamic indirect symbols X-Git-Tag: go1.21rc1~1435 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=e8fbad5de87f34d2e7632f94cac418c7436174ce;p=gostls13.git debug/macho: use saferio to read dynamic indirect symbols No test case because the problem can only happen for invalid data. Let the fuzzer find cases like this. For #47653 Fixes #58755 Change-Id: I5b95a21f47ec306ad90cd6221f0566c6f8b6c3ad Reviewed-on: https://go-review.googlesource.com/c/go/+/471835 Reviewed-by: Dmitri Shuralyov Reviewed-by: Dmitri Shuralyov TryBot-Result: Gopher Robot Run-TryBot: Ian Lance Taylor Reviewed-by: Ian Lance Taylor Run-TryBot: Ian Lance Taylor Auto-Submit: Ian Lance Taylor --- diff --git a/src/debug/macho/file.go b/src/debug/macho/file.go index 3e339c32c6..7cba3398fb 100644 --- a/src/debug/macho/file.go +++ b/src/debug/macho/file.go @@ -361,8 +361,8 @@ func NewFile(r io.ReaderAt) (*File, error) { "number of undefined symbols after index in dynamic symbol table command is greater than symbol table length (%d > %d)", hdr.Iundefsym+hdr.Nundefsym, len(f.Symtab.Syms)), nil} } - dat := make([]byte, hdr.Nindirectsyms*4) - if _, err := r.ReadAt(dat, int64(hdr.Indirectsymoff)); err != nil { + dat, err := saferio.ReadDataAt(r, uint64(hdr.Nindirectsyms)*4, int64(hdr.Indirectsymoff)) + if err != nil { return nil, err } x := make([]uint32, hdr.Nindirectsyms)