Skip to content

Commit

Permalink
debug/macho: use saferio to read symbol table strings
Browse files Browse the repository at this point in the history
No test case because the problem can only happen for invalid data. Let
the fuzzer find cases like this.

For golang#47653
Fixes golang#58603

Change-Id: I67fc45365c1a5b0b4b381f541bf2fee8ce8ddc3a
Reviewed-on: https://go-review.googlesource.com/c/go/+/469895
TryBot-Result: Gopher Robot <[email protected]>
Run-TryBot: Ian Lance Taylor <[email protected]>
Reviewed-by: Bryan Mills <[email protected]>
Auto-Submit: Ian Lance Taylor <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
Run-TryBot: Ian Lance Taylor <[email protected]>
  • Loading branch information
ianlancetaylor authored and johanbrandhorst committed Feb 22, 2023
1 parent 05c3653 commit b724fb9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/debug/macho/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b724fb9

Please sign in to comment.