From: Ian Lance Taylor Date: Thu, 14 Sep 2023 20:36:38 +0000 (-0700) Subject: debug/elf: don't crash on empty symbol section X-Git-Tag: go1.22rc1~770 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=517c66d4ee1b6b8842da34fe4c0519cfa1c58600;p=gostls13.git debug/elf: don't crash on empty symbol section No test case because the problem can only happen for invalid data. Let the fuzzer find cases like this. Fixes #62649 Change-Id: Ia40b4d415e3bbffaffd143ee280949ba41346579 Reviewed-on: https://go-review.googlesource.com/c/go/+/528655 Auto-Submit: Ian Lance Taylor LUCI-TryBot-Result: Go LUCI Reviewed-by: Ian Lance Taylor Reviewed-by: Matthew Dempsky Commit-Queue: Ian Lance Taylor Reviewed-by: Tobias Klauser --- diff --git a/src/debug/elf/file.go b/src/debug/elf/file.go index 4765c468d8..800c37fcd9 100644 --- a/src/debug/elf/file.go +++ b/src/debug/elf/file.go @@ -628,6 +628,9 @@ func (f *File) getSymbols32(typ SectionType) ([]Symbol, []byte, error) { if err != nil { return nil, nil, fmt.Errorf("cannot load symbol section: %w", err) } + if len(data) == 0 { + return nil, nil, errors.New("symbol section is empty") + } if len(data)%Sym32Size != 0 { return nil, nil, errors.New("length of symbol section is not a multiple of SymSize") }