1
0
mirror of https://github.com/golang/go synced 2024-11-17 18:04:48 -07:00

internal/xcoff: use saferio to read string table

No test case because the problem can only happen for invalid data.
Let the fuzzer find cases like this.

For #47653
Fixes #52526

Change-Id: Id90a5e391a4f684f45f8d7e32608eb03b8081076
Reviewed-on: https://go-review.googlesource.com/c/go/+/413875
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
This commit is contained in:
Ian Lance Taylor 2022-06-23 16:36:08 -07:00 committed by Gopher Robot
parent 7adfa82726
commit 0d8efa6e84

View File

@ -9,6 +9,7 @@ import (
"debug/dwarf"
"encoding/binary"
"fmt"
"internal/saferio"
"io"
"os"
"strings"
@ -213,13 +214,11 @@ func NewFile(r io.ReaderAt) (*File, error) {
return nil, err
}
if l > 4 {
if _, err := sr.Seek(int64(offset), io.SeekStart); err != nil {
return nil, err
}
f.StringTable = make([]byte, l)
if _, err := io.ReadFull(sr, f.StringTable); err != nil {
st, err := saferio.ReadDataAt(sr, uint64(l), int64(offset))
if err != nil {
return nil, err
}
f.StringTable = st
}
// Read section headers