go/src/debug/pe
Ian Lance Taylor 069f9fb205 debug/pe: return error on reading from section with uninitialized data
A section with uninitialized data contains no bytes and occupies
no space in the file. This change makes it return an error on reading
from this section so that it will force the caller to check for
a section with uninitialized data.

This is the debug/pe version of CL 429601.

This will break programs that expect a byte slice with the length
described by the SizeOfRawData field. There are two reasons to
introduce this breaking change: 1) uninitialized data is uninitialized
and there is no reason to allocate memory for it; 2) it could result
in an OOM if the file is corrupted and has a large invalid SizeOfRawData.

No test case because the problem can only happen for invalid data. Let
the fuzzer find cases like this.

For #47653
Fixes #59817

Change-Id: I1ae94e9508f803b37926275d9a571f724a09af9f
Reviewed-on: https://go-review.googlesource.com/c/go/+/488475
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: kortschak <dan@kortschak.io>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-05-01 02:25:16 +00:00
..
testdata debug/pe: add APIs for reading section def aux info 2022-03-31 14:57:35 +00:00
file.go debug/pe: return error on reading from section with uninitialized data 2023-05-01 02:25:16 +00:00
file_cgo_test.go all: remove more leftover // +build lines 2021-11-06 10:24:44 +00:00
file_test.go debug/pe: return error on reading from section with uninitialized data 2023-05-01 02:25:16 +00:00
pe.go debug/pe: add IMAGE_FILE_MACHINE_RISCV{32,64,128} 2022-08-09 01:21:43 +00:00
section.go debug/pe: return error on reading from section with uninitialized data 2023-05-01 02:25:16 +00:00
string.go internal/saferio: new package to avoid OOM 2022-08-11 20:05:25 +00:00
symbol.go all: fix typos in go file comments 2023-01-20 03:27:26 +00:00
symbols_test.go debug/pe: rework reading of aux symbols to fix endianity problems 2022-05-06 18:07:48 +00:00