1
0
mirror of https://github.com/golang/go synced 2024-11-23 06:10:05 -07:00

debug/elf: return error in DynValue for invalid dynamic section size

This is a follow-up to CL 536400.

Fixes #64446

Change-Id: I35646732f62cb1937fd448f94ea518544d4295d4
GitHub-Last-Rev: 55db18a909
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>
This commit is contained in:
Jes Cok 2023-11-29 16:23:18 +00:00 committed by Than McIntosh
parent a27a525d1b
commit b4fa5b163d

View File

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