]> Cypherpunks repositories - gostls13.git/commitdiff
debug/macho: use saferio to read symbol table strings
authorIan Lance Taylor <iant@golang.org>
Tue, 21 Feb 2023 18:14:20 +0000 (10:14 -0800)
committerGopher Robot <gobot@golang.org>
Tue, 21 Feb 2023 23:27:49 +0000 (23:27 +0000)
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 <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

src/debug/macho/file.go

index ecde25ab8917e8f377859ea3d72e0c9a63613034..9806c270bfadc1033846e715a0ba32a27a00b2be 100644 (file)
@@ -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