summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2013-11-13 08:55:09 +0000
committerkib <kib@FreeBSD.org>2013-11-13 08:55:09 +0000
commit2e0b8010f904b462d9b7c36810bad096734da8c2 (patch)
treeb84300ae7ca33c45d327be56d91634cc941c58d5
parentc917df04fa3c99b581e7548f4b0bd7a5db94454b (diff)
downloadFreeBSD-src-2e0b8010f904b462d9b7c36810bad096734da8c2.zip
FreeBSD-src-2e0b8010f904b462d9b7c36810bad096734da8c2.tar.gz
Remove useless comparisions of assigned offset and resid with the
sources from uio. Both uio_offset and offset, and uio_resid and resid have the same types for some time. Add check for buflen overflow by comparing the buflen with both offset and resid (vs. comparing with offset only, as it is currently done). Reported and tested by: pho Approved by: des (pseudofs maintainer) Sponsored by: The FreeBSD Foundation MFC after: 1 week
-rw-r--r--sys/fs/pseudofs/pseudofs_vnops.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/sys/fs/pseudofs/pseudofs_vnops.c b/sys/fs/pseudofs/pseudofs_vnops.c
index 9f97cd3..b6021b1 100644
--- a/sys/fs/pseudofs/pseudofs_vnops.c
+++ b/sys/fs/pseudofs/pseudofs_vnops.c
@@ -654,11 +654,13 @@ pfs_read(struct vop_read_args *va)
goto ret;
}
+ resid = uio->uio_resid;
+ offset = uio->uio_offset;
+ buflen = offset + resid;
+
/* beaucoup sanity checks so we don't ask for bogus allocation */
- if (uio->uio_offset < 0 || uio->uio_resid < 0 ||
- (offset = uio->uio_offset) != uio->uio_offset ||
- (resid = uio->uio_resid) != uio->uio_resid ||
- (buflen = offset + resid) < offset || buflen >= INT_MAX) {
+ if (resid < 0 || buflen < offset || buflen < resid ||
+ buflen >= INT_MAX) {
error = EINVAL;
goto ret;
}
OpenPOWER on IntegriCloud