diff options
author | Dan Kortschak <dan@kortschak.io> | 2022-08-27 12:49:25 +0930 |
---|---|---|
committer | Alex Brainman <alex.brainman@gmail.com> | 2022-09-18 01:17:32 +0000 |
commit | 63d05642d48ec81637481518df962f2b3be435a3 (patch) | |
tree | b3e3682a6f450215b381143aedaae0504e741ae9 /src/debug | |
parent | a7bcc94719a5a79241aa3ce35c1e2dbb83b94af7 (diff) | |
download | go-63d05642d48ec81637481518df962f2b3be435a3.tar.gz |
debug/pe: be careful to avoid potential uint32 overflow
Change-Id: Ic3c1c972bec39e14ea1af50ab2b5d887dac29eab
Reviewed-on: https://go-review.googlesource.com/c/go/+/426114
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Dan Kortschak <dan@kortschak.io>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Diffstat (limited to 'src/debug')
-rw-r--r-- | src/debug/pe/file.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/debug/pe/file.go b/src/debug/pe/file.go index 7adf3e122e..84bc300d92 100644 --- a/src/debug/pe/file.go +++ b/src/debug/pe/file.go @@ -353,7 +353,10 @@ func (f *File) ImportedSymbols() ([]string, error) { var ds *Section ds = nil for _, s := range f.Sections { - if s.VirtualAddress <= idd.VirtualAddress && idd.VirtualAddress < s.VirtualAddress+s.VirtualSize { + // We are using distance between s.VirtualAddress and idd.VirtualAddress + // to avoid potential overflow of uint32 caused by addition of s.VirtualSize + // to s.VirtualAddress. + if s.VirtualAddress <= idd.VirtualAddress && idd.VirtualAddress-s.VirtualAddress < s.VirtualSize { ds = s break } |