]> Cypherpunks.ru repositories - gostls13.git/commitdiff
debug/elf: return error in DynString for invalid dynamic section size
authorIan Lance Taylor <iant@golang.org>
Thu, 19 Oct 2023 00:30:31 +0000 (17:30 -0700)
committerGopher Robot <gobot@golang.org>
Wed, 25 Oct 2023 19:25:38 +0000 (19:25 +0000)
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>
src/debug/elf/file.go

index e748716cb75ffb9b947373be9e8ed9c4abf3375a..fcbe76b195bd20f8ec423ab9ff87e53515017700 100644 (file)
@@ -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