]> Cypherpunks repositories - gostls13.git/commitdiff
debug/pe: fix off by one error in valid symbol index test
authorThan McIntosh <thanm@google.com>
Mon, 25 Apr 2022 15:22:10 +0000 (11:22 -0400)
committerThan McIntosh <thanm@google.com>
Mon, 25 Apr 2022 15:42:53 +0000 (15:42 +0000)
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 <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/debug/pe/symbol.go

index 0dfd5d90b8758552435adf1644989eff6b210e12..323fa8c3df6a5e8e70aeec9a7fa370e6d927d9a7 100644 (file)
@@ -136,10 +136,9 @@ const (
 // auxiliary symbols: https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#auxiliary-symbol-records
 // COMDAT sections: https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#comdat-sections-object-only
 // auxiliary info for section definitions: https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#auxiliary-format-5-section-definitions
-//
 func (f *File) COFFSymbolReadSectionDefAux(idx int) (*COFFSymbolAuxFormat5, error) {
        var rv *COFFSymbolAuxFormat5
-       if idx < 0 || idx > len(f.COFFSymbols) {
+       if idx < 0 || idx >= len(f.COFFSymbols) {
                return rv, fmt.Errorf("invalid symbol index")
        }
        pesym := &f.COFFSymbols[idx]