]> Cypherpunks.ru repositories - gostls13.git/commitdiff
debug/plan9obj: don't crash on EOF before symbol type
authorIan Lance Taylor <iant@golang.org>
Tue, 23 Aug 2022 00:42:54 +0000 (17:42 -0700)
committerGopher Robot <gobot@golang.org>
Tue, 23 Aug 2022 20:32:50 +0000 (20:32 +0000)
No debug/plan9obj test case because the problem can only happen for
invalid data. Let the fuzzer find cases like this.

For #47653
Fixes #54585

Change-Id: I8d3e15725b9bc09dd0e6f2750769987021f5e982
Reviewed-on: https://go-review.googlesource.com/c/go/+/425115
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
src/debug/plan9obj/file.go

index aa25809148cd40605b754d477269ab7b0b6d79d8..2b83f9bdffaac5b2755a4a91c94bd48c28032c96 100644 (file)
@@ -212,6 +212,9 @@ func walksymtab(data []byte, ptrsz int, fn func(sym) error) error {
                        p = p[4:]
                }
 
+               if len(p) < 1 {
+                       return &formatError{len(data), "unexpected EOF", nil}
+               }
                typ := p[0] & 0x7F
                s.typ = typ
                p = p[1:]