Skip to content

Commit 553f02c

Browse files
tklausergopherbot
authored andcommitted
debug/macho: use saferio to allocate load command slice
Avoid allocating large amounts of memory for corrupt input. No test case because the problem can only happen for invalid data. Let the fuzzer find cases like this. Fixes #54780 Change-Id: Icdacb16bef7d29ef431da52e6d1da4e883a3e050 Reviewed-on: https://go-review.googlesource.com/c/go/+/427434 Run-TryBot: Tobias Klauser <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: Heschi Kreinick <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Auto-Submit: Tobias Klauser <[email protected]>
1 parent 6605686 commit 553f02c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/debug/macho/file.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ func NewFile(r io.ReaderAt) (*File, error) {
249249
if f.Magic == Magic64 {
250250
offset = fileHeaderSize64
251251
}
252-
dat := make([]byte, f.Cmdsz)
253-
if _, err := r.ReadAt(dat, offset); err != nil {
252+
dat, err := saferio.ReadDataAt(r, uint64(f.Cmdsz), offset)
253+
if err != nil {
254254
return nil, err
255255
}
256256
c := saferio.SliceCap([]Load{}, uint64(f.Ncmd))

0 commit comments

Comments
 (0)