Skip to content

Commit b4fa5b1

Browse files
callthingsoffthanm
authored andcommitted
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: 55db18a GitHub-Pull-Request: #64448 Reviewed-on: https://go-review.googlesource.com/c/go/+/545835 LUCI-TryBot-Result: Go LUCI <[email protected]> Run-TryBot: Jes Cok <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Than McIntosh <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent a27a525 commit b4fa5b1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/debug/elf/file.go

+8
Original file line numberDiff line numberDiff line change
@@ -1656,6 +1656,14 @@ func (f *File) DynValue(tag DynTag) ([]uint64, error) {
16561656
return nil, err
16571657
}
16581658

1659+
dynSize := 8
1660+
if f.Class == ELFCLASS64 {
1661+
dynSize = 16
1662+
}
1663+
if len(d)%dynSize != 0 {
1664+
return nil, errors.New("length of dynamic section is not a multiple of dynamic entry size")
1665+
}
1666+
16591667
// Parse the .dynamic section as a string of bytes.
16601668
var vals []uint64
16611669
for len(d) > 0 {

0 commit comments

Comments
 (0)