diff options
| author | Ian Lance Taylor <iant@golang.org> | 2023-10-18 17:30:31 -0700 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2023-10-25 19:25:38 +0000 |
| commit | 57322b3cbf1ed26c3b19c6edcd5758c794a36467 (patch) | |
| tree | ca532edecf3183ee20004d186e845c31eb1ad875 /src/debug | |
| parent | 9cdcb01320d9a866e46a2daedb9bde16e0d51278 (diff) | |
| download | go-57322b3cbf1ed26c3b19c6edcd5758c794a36467.tar.xz | |
debug/elf: return error in DynString for invalid dynamic section size
No test case because the problem can only happen for invalid data.
Let the fuzzer find cases like this.
Fixes #63610
Change-Id: I797b4d9bdb08286ad3e3a9a6f800ee8c90cb7261
Reviewed-on: https://go-review.googlesource.com/c/go/+/536400
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Diffstat (limited to 'src/debug')
| -rw-r--r-- | src/debug/elf/file.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/debug/elf/file.go b/src/debug/elf/file.go index e748716cb7..fcbe76b195 100644 --- a/src/debug/elf/file.go +++ b/src/debug/elf/file.go @@ -1607,6 +1607,15 @@ func (f *File) DynString(tag DynTag) ([]string, error) { if err != nil { return nil, err } + + dynSize := 8 + if f.Class == ELFCLASS64 { + dynSize = 16 + } + if len(d)%dynSize != 0 { + return nil, errors.New("length of dynamic section is not a multiple of dynamic entry size") + } + str, err := f.stringTable(ds.Link) if err != nil { return nil, err |
