summaryrefslogtreecommitdiff
path: root/sys/msdosfs
diff options
context:
space:
mode:
authorStefan Kempf <stefan@cvs.openbsd.org>2016-02-05 19:27:03 +0000
committerStefan Kempf <stefan@cvs.openbsd.org>2016-02-05 19:27:03 +0000
commit826c722febf68f99a454f9f10fd1d0b33476f1b9 (patch)
tree2da21e359e6391729fa960b9230c42fe11bdefa5 /sys/msdosfs
parent4eb4c7a624122c1e1cab27326e33f3a8ab7f78ea (diff)
Guard against integer overflow when checking whether
writing to a file on msdosfs stays within the max. file size. ok kettenis@, krw@
Diffstat (limited to 'sys/msdosfs')
-rw-r--r--sys/msdosfs/msdosfs_vnops.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/msdosfs/msdosfs_vnops.c b/sys/msdosfs/msdosfs_vnops.c
index dfdddd19e4f..b3c9db1de6d 100644
--- a/sys/msdosfs/msdosfs_vnops.c
+++ b/sys/msdosfs/msdosfs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: msdosfs_vnops.c,v 1.106 2016/01/27 17:09:41 stefan Exp $ */
+/* $OpenBSD: msdosfs_vnops.c,v 1.107 2016/02/05 19:27:02 stefan Exp $ */
/* $NetBSD: msdosfs_vnops.c,v 1.63 1997/10/17 11:24:19 ws Exp $ */
/*-
@@ -626,7 +626,8 @@ msdosfs_write(void *v)
return (0);
/* Don't bother to try to write files larger than the f/s limit */
- if (uio->uio_offset + uio->uio_resid > MSDOSFS_FILESIZE_MAX)
+ if (uio->uio_offset > MSDOSFS_FILESIZE_MAX ||
+ uio->uio_resid > (MSDOSFS_FILESIZE_MAX - uio->uio_offset))
return (EFBIG);
/* do the filesize rlimit check */