summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2007-04-19 05:54:45 +0000
committerpjd <pjd@FreeBSD.org>2007-04-19 05:54:45 +0000
commite728588aa7cb67001986ab4315f45661a326b60f (patch)
tree4bb224435804ed9d9e949d96e9cfb78afe8d4161
parenta10280e050436a2493f47fad1138c3291eb81b18 (diff)
downloadFreeBSD-src-e728588aa7cb67001986ab4315f45661a326b60f.zip
FreeBSD-src-e728588aa7cb67001986ab4315f45661a326b60f.tar.gz
Fix a bug in sendfile(2) when files larger than page size and nbytes=0.
When nbytes=0, sendfile(2) should use file size. Because of the bug, it was sending half of a file. The bug is that 'off' variable can't be used for size calculation, because it changes inside the loop, so we should use uap->offset instead.
-rw-r--r--sys/kern/uipc_syscalls.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index b1ab79c..d9e9f10 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -2016,12 +2016,12 @@ retry_space:
*/
pgoff = (vm_offset_t)(off & PAGE_MASK);
xfsize = omin(PAGE_SIZE - pgoff,
- obj->un_pager.vnp.vnp_size - off -
+ obj->un_pager.vnp.vnp_size - uap->offset -
sbytes - loopbytes);
if (uap->nbytes)
rem = (uap->nbytes - sbytes - loopbytes);
else
- rem = obj->un_pager.vnp.vnp_size - off -
+ rem = obj->un_pager.vnp.vnp_size - uap->offset -
sbytes - loopbytes;
xfsize = omin(rem, xfsize);
if (xfsize <= 0) {
OpenPOWER on IntegriCloud