]> Cypherpunks.ru repositories - gostls13.git/commitdiff
debug/macho: use saferio to read dynamic indirect symbols
authorIan Lance Taylor <iant@golang.org>
Mon, 27 Feb 2023 23:52:52 +0000 (15:52 -0800)
committerGopher Robot <gobot@golang.org>
Tue, 28 Feb 2023 06:02:49 +0000 (06:02 +0000)
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 <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

src/debug/macho/file.go

index 3e339c32c6a2f3f96b80bd94ef695d6c738c089c..7cba3398fbca07a63f71e29ba61782dc0a4f9efb 100644 (file)
@@ -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)