aboutsummaryrefslogtreecommitdiff
path: root/src/debug
diff options
context:
space:
mode:
Diffstat (limited to 'src/debug')
-rw-r--r--src/debug/buildinfo/buildinfo.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/debug/buildinfo/buildinfo.go b/src/debug/buildinfo/buildinfo.go
index f3d38b26e8..07f835127e 100644
--- a/src/debug/buildinfo/buildinfo.go
+++ b/src/debug/buildinfo/buildinfo.go
@@ -380,7 +380,14 @@ func searchMagic(x exe, start, size uint64) (uint64, error) {
}
if i%buildInfoAlign != 0 {
// Found magic, but misaligned. Keep searching.
- data = data[(i+buildInfoAlign-1)&^(buildInfoAlign-1):]
+ next := (i + buildInfoAlign - 1) &^ (buildInfoAlign - 1)
+ if next > len(data) {
+ // Corrupt object file: the remaining
+ // count says there is more data,
+ // but we didn't read it.
+ return 0, errNotGoExe
+ }
+ data = data[next:]
continue
}
// Good match!