mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Handle EOF in vfs2 sendfile.
Discovered by syzkaller. PiperOrigin-RevId: 324938438
This commit is contained in:
@@ -347,6 +347,11 @@ func Sendfile(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.Sysc
|
||||
} else {
|
||||
spliceN, err = inFile.Read(t, outPipeFD.IOSequence(count), vfs.ReadOptions{})
|
||||
}
|
||||
if spliceN == 0 && err == io.EOF {
|
||||
// We reached the end of the file. Eat the error and exit the loop.
|
||||
err = nil
|
||||
break
|
||||
}
|
||||
n += spliceN
|
||||
if err == syserror.ErrWouldBlock && !nonBlock {
|
||||
err = dw.waitForBoth(t)
|
||||
@@ -367,8 +372,7 @@ func Sendfile(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.Sysc
|
||||
readN, err = inFile.Read(t, usermem.BytesIOSequence(buf), vfs.ReadOptions{})
|
||||
}
|
||||
if readN == 0 && err == io.EOF {
|
||||
// We reached the end of the file. Eat the
|
||||
// error and exit the loop.
|
||||
// We reached the end of the file. Eat the error and exit the loop.
|
||||
err = nil
|
||||
break
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user