ffs_read:
Replace wrong check returned EFBIG with EOVERFLOW handling from POSIX: 36708 [EOVERFLOW] The file is a regular file, nbyte is greater than 0, the starting position is before the end-of-file, and the starting position is greater than or equal to the offset maximum established in the open file description associated with fildes. ffs_write: Replace u_int64_t cast with uoff_t cast which is more natural for types used. ffs_write & ffs_read: Remove uio_offset and uio_resid checks for negative values, the caller supposed to do it already. Add comments about it. Reviewed by: bde
This commit is contained in:
parent
4ccecf8711
commit
a712e3f598
@ -386,13 +386,17 @@ ffs_read(ap)
|
||||
} else if (vp->v_type != VREG && vp->v_type != VDIR)
|
||||
panic("ffs_read: type %d", vp->v_type);
|
||||
#endif
|
||||
fs = ip->i_fs;
|
||||
if ((u_int64_t)uio->uio_offset > fs->fs_maxfilesize)
|
||||
return (EFBIG);
|
||||
|
||||
orig_resid = uio->uio_resid;
|
||||
if (orig_resid <= 0)
|
||||
if (orig_resid == 0)
|
||||
return (0);
|
||||
fs = ip->i_fs;
|
||||
/*
|
||||
* The caller is supposed to check if
|
||||
* uio->uio_offset >= 0 and uio->uio_resid >= 0.
|
||||
*/
|
||||
if (uio->uio_offset < ip->i_size &&
|
||||
uio->uio_offset >= fs->fs_maxfilesize)
|
||||
return (EOVERFLOW);
|
||||
|
||||
object = vp->v_object;
|
||||
|
||||
@ -641,8 +645,11 @@ ffs_write(ap)
|
||||
}
|
||||
|
||||
fs = ip->i_fs;
|
||||
if (uio->uio_offset < 0 ||
|
||||
(u_int64_t)uio->uio_offset + uio->uio_resid > fs->fs_maxfilesize) {
|
||||
/*
|
||||
* The caller is supposed to check if
|
||||
* uio->uio_offset >= 0 and uio->uio_resid >= 0.
|
||||
*/
|
||||
if ((uoff_t)uio->uio_offset + uio->uio_resid > fs->fs_maxfilesize) {
|
||||
if (object) {
|
||||
VM_OBJECT_LOCK(object);
|
||||
vm_object_vndeallocate(object);
|
||||
|
Loading…
Reference in New Issue
Block a user