summaryrefslogtreecommitdiffstats
path: root/sys/ufs
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>2004-01-23 05:38:02 +0000
committerache <ache@FreeBSD.org>2004-01-23 05:38:02 +0000
commita712e3f598f1761b1938d074a2bd96fbd0230cc3 (patch)
tree254edafa0fd168d4af21fbf69594842200b8c2b7 /sys/ufs
parent4ccecf8711032199744f3d627c0fe9ed367d1a5c (diff)
downloadFreeBSD-src-a712e3f598f1761b1938d074a2bd96fbd0230cc3.zip
FreeBSD-src-a712e3f598f1761b1938d074a2bd96fbd0230cc3.tar.gz
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
Diffstat (limited to 'sys/ufs')
-rw-r--r--sys/ufs/ffs/ffs_vnops.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c
index 8ac3b91..d16e247 100644
--- a/sys/ufs/ffs/ffs_vnops.c
+++ b/sys/ufs/ffs/ffs_vnops.c
@@ -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);
OpenPOWER on IntegriCloud