mirror of
https://github.com/golang/go.git
synced 2025-05-22 16:09:37 +00:00
cmd/link/internal/loadpe: fix xrels search "not found" detection
Fixes findHandlerInXDataAMD64 to handle the return value of sort.Search when the search fails to find anything. Otherwise, the value may later be used as an index, causing an out of range error. Fixes #64200 Change-Id: I4f92e76b3f4d4d5dbe5cbc707f808298c580afe1 Reviewed-on: https://go-review.googlesource.com/c/go/+/543076 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Carlos Amedee <carlos@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Run-TryBot: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
This commit is contained in:
parent
3f04f959d2
commit
a95c5d37f2
@ -90,16 +90,17 @@ func findHandlerInXDataAMD64(ldr *loader.Loader, xsym sym.LoaderSym, add int64)
|
||||
// unless it is chained, but we will handle this case later.
|
||||
targetOff := add + unwStaticDataSize*(1+int64(codes))
|
||||
xrels := ldr.Relocs(xsym)
|
||||
idx := sort.Search(xrels.Count(), func(i int) bool {
|
||||
xrelsCount := xrels.Count()
|
||||
idx := sort.Search(xrelsCount, func(i int) bool {
|
||||
return int64(xrels.At(i).Off()) >= targetOff
|
||||
})
|
||||
if idx == 0 {
|
||||
if idx == xrelsCount {
|
||||
return 0
|
||||
}
|
||||
if isChained {
|
||||
// The third relocations references the next .xdata entry in the chain, recurse.
|
||||
idx += 2
|
||||
if idx >= xrels.Count() {
|
||||
if idx >= xrelsCount {
|
||||
return 0
|
||||
}
|
||||
r := xrels.At(idx)
|
||||
|
Loading…
x
Reference in New Issue
Block a user