mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-06 13:09:50 +00:00
Make sendfile(2) more robust against file change. This fixes a possible
crash when the file shrinks. This also fixes sendfile(2) not sending more data in a case when the file grows, and the request is open-ended or specifies a size that is greater than old file size. PR: 217789 Reviewed by: gallatin MFC after: 10 days
This commit is contained in:
parent
e4deb071bd
commit
9e3c8bd3e2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=315910
@ -689,11 +689,10 @@ vn_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio,
|
||||
goto done;
|
||||
}
|
||||
if (va.va_size != obj_size) {
|
||||
if (nbytes == 0)
|
||||
rem += va.va_size - obj_size;
|
||||
else if (offset + nbytes > va.va_size)
|
||||
rem -= (offset + nbytes - va.va_size);
|
||||
obj_size = va.va_size;
|
||||
rem = nbytes ?
|
||||
omin(nbytes + offset, obj_size) : obj_size;
|
||||
rem -= off;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user