Skip to content

Commit 94f25ec

Browse files
committed
debug/pe: fix off by one error in valid symbol index test
Fix an off-by-one error in COFFSymbolReadSectionDefAux, specifically the code that tests whether a symbol index is valid. Fixes #52525. Change-Id: I1b6e5dacfd99249c694bef5ae606e90fdb2ef521 Reviewed-on: https://go-review.googlesource.com/c/go/+/402156 Run-TryBot: Than McIntosh <[email protected]> Reviewed-by: Cherry Mui <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent 6b1d9ae commit 94f25ec

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/debug/pe/symbol.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,9 @@ const (
136136
// auxiliary symbols: https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#auxiliary-symbol-records
137137
// COMDAT sections: https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#comdat-sections-object-only
138138
// auxiliary info for section definitions: https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#auxiliary-format-5-section-definitions
139-
//
140139
func (f *File) COFFSymbolReadSectionDefAux(idx int) (*COFFSymbolAuxFormat5, error) {
141140
var rv *COFFSymbolAuxFormat5
142-
if idx < 0 || idx > len(f.COFFSymbols) {
141+
if idx < 0 || idx >= len(f.COFFSymbols) {
143142
return rv, fmt.Errorf("invalid symbol index")
144143
}
145144
pesym := &f.COFFSymbols[idx]

0 commit comments

Comments
 (0)