From: Ian Lance Taylor Date: Sun, 24 Aug 2025 20:17:56 +0000 (-0700) Subject: debug/elf: don't panic if symtab too small X-Git-Tag: go1.26rc1~1010 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=765905e3bd13dcb048388890dba2ea47f6e58711;p=gostls13.git debug/elf: don't panic if symtab too small No test case because the problem can only happen for invalid data. Let the fuzzer find cases like this. For #47653 Fixes #75130 Change-Id: Ie6015564bb98334377383bbc16d79119dc4e36f9 Reviewed-on: https://go-review.googlesource.com/c/go/+/698855 Reviewed-by: Tobias Klauser Auto-Submit: Ian Lance Taylor Reviewed-by: Carlos Amedee LUCI-TryBot-Result: Go LUCI Reviewed-by: Cherry Mui Reviewed-by: Florian Lehner --- diff --git a/src/debug/elf/file.go b/src/debug/elf/file.go index 89bd70b5b2..50452b5bef 100644 --- a/src/debug/elf/file.go +++ b/src/debug/elf/file.go @@ -692,6 +692,9 @@ func (f *File) getSymbols64(typ SectionType) ([]Symbol, []byte, error) { if len(data)%Sym64Size != 0 { return nil, nil, errors.New("length of symbol section is not a multiple of Sym64Size") } + if len(data) == 0 { + return nil, nil, ErrNoSymbols + } strdata, err := f.stringTable(symtabSection.Link) if err != nil {