Skip to content

debug/elf: guard access to File.gnuVersym #56431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/debug/elf/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -1570,12 +1570,16 @@ func (f *File) gnuVersionInit(str []byte) bool {
// gnuVersion adds Library and Version information to sym,
// which came from offset i of the symbol table.
func (f *File) gnuVersion(i int) (library string, version string) {
// Each entry is two bytes.
// Each entry is two bytes; skip undef entry at beginning.
i = (i + 1) * 2
if i >= len(f.gnuVersym) {
return
}
j := int(f.ByteOrder.Uint16(f.gnuVersym[i:]))
s := f.gnuVersym[i:]
if len(s) < 2 {
return
}
j := int(f.ByteOrder.Uint16(s))
if j < 2 || j >= len(f.gnuNeed) {
return
}
Expand Down