]> Cypherpunks repositories - gostls13.git/commitdiff
debug/elf: don't panic if symtab too small
authorIan Lance Taylor <iant@golang.org>
Sun, 24 Aug 2025 20:17:56 +0000 (13:17 -0700)
committerGopher Robot <gobot@golang.org>
Thu, 28 Aug 2025 02:46:19 +0000 (19:46 -0700)
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 <tobias.klauser@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Florian Lehner <lehner.florian86@gmail.com>
src/debug/elf/file.go

index 89bd70b5b2a87c0f492a336ab218f9858697eeb4..50452b5bef45f4ef019321af18498f6b3cec7dc7 100644 (file)
@@ -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 {