aboutsummaryrefslogtreecommitdiff
path: root/src/debug
diff options
context:
space:
mode:
Diffstat (limited to 'src/debug')
-rw-r--r--src/debug/elf/file.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/debug/elf/file.go b/src/debug/elf/file.go
index e93200a11d..5f339596a7 100644
--- a/src/debug/elf/file.go
+++ b/src/debug/elf/file.go
@@ -325,6 +325,13 @@ func NewFile(r io.ReaderAt) (*File, error) {
shstrndx = int(hdr.Shstrndx)
}
+ if shoff < 0 {
+ return nil, &FormatError{0, "invalid shoff", shoff}
+ }
+ if phoff < 0 {
+ return nil, &FormatError{0, "invalid phoff", phoff}
+ }
+
if shoff == 0 && shnum != 0 {
return nil, &FormatError{0, "invalid ELF shnum for shoff=0", shnum}
}
@@ -419,6 +426,12 @@ func NewFile(r io.ReaderAt) (*File, error) {
Entsize: sh.Entsize,
}
}
+ if int64(s.Offset) < 0 {
+ return nil, &FormatError{off, "invalid section offset", int64(s.Offset)}
+ }
+ if int64(s.FileSize) < 0 {
+ return nil, &FormatError{off, "invalid section size", int64(s.FileSize)}
+ }
s.sr = io.NewSectionReader(r, int64(s.Offset), int64(s.FileSize))
if s.Flags&SHF_COMPRESSED == 0 {