Skip to content

Commit daf53d3

Browse files
committed
debug/elf: return error in DynValue for invalid dynamic section size
This is a follow-up to CL 536400. Fixes #64446
1 parent 6111acc commit daf53d3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/debug/elf/file.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,6 +1659,14 @@ func (f *File) DynValue(tag DynTag) ([]uint64, error) {
16591659
// Parse the .dynamic section as a string of bytes.
16601660
var vals []uint64
16611661
for len(d) > 0 {
1662+
dynSize := 8
1663+
if f.Class == ELFCLASS64 {
1664+
dynSize = 16
1665+
}
1666+
if len(d)%dynSize != 0 {
1667+
return nil, errors.New("length of dynamic section is not a multiple of dynamic entry size")
1668+
}
1669+
16621670
var t DynTag
16631671
var v uint64
16641672
switch f.Class {

0 commit comments

Comments
 (0)