proc: bugfix: unsigned integer overflow in proc.(*memCache).contains (#555)
Fixes #554
This commit is contained in:
parent
fa1db367fe
commit
5933a0f48f
@ -14,7 +14,7 @@ type memCache struct {
|
||||
}
|
||||
|
||||
func (m *memCache) contains(addr uintptr, size int) bool {
|
||||
return addr >= m.cacheAddr && (addr+uintptr(size)) <= (m.cacheAddr+uintptr(len(m.cache)))
|
||||
return addr >= m.cacheAddr && addr <= (m.cacheAddr+uintptr(len(m.cache) - size))
|
||||
}
|
||||
|
||||
func (m *memCache) readMemory(addr uintptr, size int) (data []byte, err error) {
|
||||
|
@ -1741,3 +1741,12 @@ func TestIssue462(t *testing.T) {
|
||||
assertNoError(err, t, "Stacktrace()")
|
||||
})
|
||||
}
|
||||
|
||||
func TestIssue554(t *testing.T) {
|
||||
// unsigned integer overflow in proc.(*memCache).contains was
|
||||
// causing it to always return true for address 0xffffffffffffffff
|
||||
mem := memCache{0x20, make([]byte, 100), nil}
|
||||
if mem.contains(0xffffffffffffffff, 40) {
|
||||
t.Fatalf("should be false")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user