]> Cypherpunks repositories - gostls13.git/commitdiff
debug/elf: return error in DynValue for invalid dynamic section size
authorJes Cok <xigua67damn@gmail.com>
Wed, 29 Nov 2023 16:23:18 +0000 (16:23 +0000)
committerThan McIntosh <thanm@google.com>
Thu, 30 Nov 2023 13:03:03 +0000 (13:03 +0000)
This is a follow-up to CL 536400.

Fixes #64446

Change-Id: I35646732f62cb1937fd448f94ea518544d4295d4
GitHub-Last-Rev: 55db18a909fd44e6b2f2b98fd1a44ad01bb37932
GitHub-Pull-Request: golang/go#64448
Reviewed-on: https://go-review.googlesource.com/c/go/+/545835
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Jes Cok <xigua67damn@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/debug/elf/file.go

index fcbe76b195bd20f8ec423ab9ff87e53515017700..7228447c2128fec48dbd9b8aaf23c6bdb51b0377 100644 (file)
@@ -1656,6 +1656,14 @@ func (f *File) DynValue(tag DynTag) ([]uint64, error) {
                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")
+       }
+
        // Parse the .dynamic section as a string of bytes.
        var vals []uint64
        for len(d) > 0 {