From b724fb93a6158fe8e700cf22fa2d431b460308fc Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 21 Feb 2023 10:14:20 -0800 Subject: [PATCH] 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 --- src/debug/macho/file.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/debug/macho/file.go b/src/debug/macho/file.go index ecde25ab8917e8..9806c270bfadc1 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