]> Cypherpunks repositories - gostls13.git/commit
debug/buildinfo: stop searchMagic search at EOF
authorMichael Pratt <mpratt@google.com>
Tue, 27 Aug 2024 15:13:46 +0000 (11:13 -0400)
committerMichael Pratt <mpratt@google.com>
Tue, 27 Aug 2024 17:29:18 +0000 (17:29 +0000)
commit61e00ae134193b8db6c5a3083b51d5bc2c15e18f
tree001c33674145f5ea50bf53d4c7878be3bd52f36f
parentaa2e8b9ce2a344f46dfc6346f5ea83c573784464
debug/buildinfo: stop searchMagic search at EOF

An invalid executable may claim to have a data section bigger than the
executable, causing readData in searchMagic to hit EOF. Since readData
suppresses all EOF errors, searchData would keep attempting to search
through a potentially huge "section" despite readData continuously
failing.

Fix by suppressing EOF only on partial read. If nothing is read, allow
EOF. Note that most of the admittedly tedious EOF handling in this
package is around ensuring we return errNotGoExe in most cases.

This was discovered by the new fuzz test. This fuzz test was inspired
by #69066, though it has not found that specific bug.

Change-Id: Icf413e996cecc583c084c9e44249b9294c3d8f10
Reviewed-on: https://go-review.googlesource.com/c/go/+/608637
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/debug/buildinfo/buildinfo.go
src/debug/buildinfo/buildinfo_test.go
src/debug/buildinfo/testdata/fuzz/FuzzRead/36aeb674e3454016 [new file with mode: 0644]