Verify that when offset address is not null, infile must be seekable

Change-Id: Id247399baeac58f6cd774acabd5d1da05e5b5697
PiperOrigin-RevId: 196887768
This commit is contained in:
Chanwit Kaewkasi
2018-05-16 14:20:24 -07:00
committed by Shentubot
parent 5b4c20e1b8
commit 3131a6b131
+4
View File
@@ -1915,6 +1915,10 @@ func Sendfile(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.Sysc
hasOffset := offsetAddr != 0
// If we have a provided offset.
if hasOffset {
// Verify that when offset address is not null, infile must be seekable
if !inFile.Flags().Pread {
return 0, nil, syserror.ESPIPE
}
// Copy in the offset.
if _, err := t.CopyIn(offsetAddr, &offset); err != nil {
return 0, nil, err