mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Add checks for short CopyOut in rpcinet
PiperOrigin-RevId: 199864753 Change-Id: Ibace6a1fdf99ee6ce368ac12c390aa8a02dbdfb7
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user