svn commit: r316431 - stable/11/sys/kern
Gleb Smirnoff
glebius at FreeBSD.org
Mon Apr 3 00:46:33 UTC 2017
Author: glebius
Date: Mon Apr 3 00:46:32 2017
New Revision: 316431
URL: https://svnweb.freebsd.org/changeset/base/316431
Log:
Merge r315910:
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
Modified:
stable/11/sys/kern/kern_sendfile.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sys/kern/kern_sendfile.c
==============================================================================
--- stable/11/sys/kern/kern_sendfile.c Sun Apr 2 21:30:05 2017 (r316430)
+++ stable/11/sys/kern/kern_sendfile.c Mon Apr 3 00:46:32 2017 (r316431)
@@ -681,11 +681,10 @@ retry_space:
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;
}
}
More information about the svn-src-all
mailing list