Fix PTRACE_GETREGSET write size

The existing logic is backwards and writes iov_len == 0 for a full write.

PiperOrigin-RevId: 217560377
Change-Id: I5a39c31bf0ba9063a8495993bfef58dc8ab7c5fa
This commit is contained in:
Michael Pratt
2018-10-17 11:53:04 -07:00
committed by Shentubot
parent 6cba410df0
commit 578fe5a50d
+7 -1
View File
@@ -921,7 +921,13 @@ func (t *Task) Ptrace(req int64, pid ThreadID, addr, data usermem.Addr) error {
if err != nil {
return err
}
ar.End -= usermem.Addr(n)
// Update iovecs to represent the range of the written register set.
end, ok := ar.Start.AddLength(uint64(n))
if !ok {
panic(fmt.Sprintf("%#x + %#x overflows. Invalid reg size > %#x", ar.Start, n, ar.Length()))
}
ar.End = end
return t.CopyOutIovecs(data, usermem.AddrRangeSeqOf(ar))
case linux.PTRACE_SETREGS: