summaryrefslogtreecommitdiff
path: root/libgo/go/debug/elf/file.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/debug/elf/file.go')
-rw-r--r--libgo/go/debug/elf/file.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/libgo/go/debug/elf/file.go b/libgo/go/debug/elf/file.go
index bd6146437c9..1a5424f54e8 100644
--- a/libgo/go/debug/elf/file.go
+++ b/libgo/go/debug/elf/file.go
@@ -276,7 +276,6 @@ func NewFile(r io.ReaderAt) (*File, error) {
var phentsize, phnum int
var shoff int64
var shentsize, shnum, shstrndx int
- shstrndx = -1
switch f.Class {
case ELFCLASS32:
hdr := new(Header32)
@@ -318,7 +317,11 @@ func NewFile(r io.ReaderAt) (*File, error) {
shstrndx = int(hdr.Shstrndx)
}
- if shnum > 0 && shoff > 0 && (shstrndx < 0 || shstrndx >= shnum) {
+ if shoff == 0 && shnum != 0 {
+ return nil, &FormatError{0, "invalid ELF shnum for shoff=0", shnum}
+ }
+
+ if shnum > 0 && shstrndx >= shnum {
return nil, &FormatError{0, "invalid ELF shstrndx", shstrndx}
}