Add checks for short CopyOut in rpcinet

PiperOrigin-RevId: 199864753
Change-Id: Ibace6a1fdf99ee6ce368ac12c390aa8a02dbdfb7
This commit is contained in:
Brian Geffon
2018-06-08 15:58:22 -07:00
committed by Shentubot
parent 6728f09910
commit 2fbd1cf57c
+8 -2
View File
@@ -465,7 +465,10 @@ func (s *socketOperations) RecvMsg(t *kernel.Task, dst usermem.IOSequence, flags
res, err := rpcRecvMsg(t, req)
if err == nil {
_, e := dst.CopyOut(t, res.Data)
n, e := dst.CopyOut(t, res.Data)
if e == nil && n != len(res.Data) {
panic("CopyOut failed to copy full buffer")
}
return int(res.Length), res.Address.GetAddress(), res.Address.GetLength(), socket.ControlMessages{}, syserr.FromError(e)
}
if err != syserr.ErrWouldBlock || flags&linux.MSG_DONTWAIT != 0 {
@@ -481,7 +484,10 @@ func (s *socketOperations) RecvMsg(t *kernel.Task, dst usermem.IOSequence, flags
for {
res, err := rpcRecvMsg(t, req)
if err == nil {
_, e := dst.CopyOut(t, res.Data)
n, e := dst.CopyOut(t, res.Data)
if e == nil && n != len(res.Data) {
panic("CopyOut failed to copy full buffer")
}
return int(res.Length), res.Address.GetAddress(), res.Address.GetLength(), socket.ControlMessages{}, syserr.FromError(e)
}
if err != syserr.ErrWouldBlock {