Skip to content

Commit dbd0ce8

Browse files
kortschakgopherbot
authored andcommitted
debug/elf: validate offset and file size ranges
Change-Id: Iebe31b91c6e81438120f50a8089a8efca3d5339d Reviewed-on: https://go-review.googlesource.com/c/go/+/426115 Run-TryBot: Dan Kortschak <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: Heschi Kreinick <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent 59bdbb3 commit dbd0ce8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/debug/elf/file.go

+6
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,12 @@ func NewFile(r io.ReaderAt) (*File, error) {
377377
Align: ph.Align,
378378
}
379379
}
380+
if int64(p.Off) < 0 {
381+
return nil, &FormatError{off, "invalid program header offset", p.Off}
382+
}
383+
if int64(p.Filesz) < 0 {
384+
return nil, &FormatError{off, "invalid program header file size", p.Filesz}
385+
}
380386
p.sr = io.NewSectionReader(r, int64(p.Off), int64(p.Filesz))
381387
p.ReaderAt = p.sr
382388
f.Progs[i] = p

0 commit comments

Comments
 (0)