diff options
author | Tom Cosgrove <tom@cvs.openbsd.org> | 2005-03-01 14:24:34 +0000 |
---|---|---|
committer | Tom Cosgrove <tom@cvs.openbsd.org> | 2005-03-01 14:24:34 +0000 |
commit | e177759a416ea6ef09860382e66d9a3afc94a7fe (patch) | |
tree | 8892a63a25752b48fbc1612e09876ab2fff64c3b /sys/msdosfs | |
parent | ea6860c8fa6e53eac4959352c39b2a1447bbbab6 (diff) |
The maximum file size on MS-DOS filesystems is 4 GB - 1 byte, so
don't bother trying to write files bigger than this. Just return
EFBIG to caller, rather than panic()ing later.
Closes PR 4090. Assistance from otto@, tested by OP and moritz@;
thanks.
ok tedu@ deraadt@
Diffstat (limited to 'sys/msdosfs')
-rw-r--r-- | sys/msdosfs/denode.h | 5 | ||||
-rw-r--r-- | sys/msdosfs/msdosfs_vnops.c | 6 |
2 files changed, 9 insertions, 2 deletions
diff --git a/sys/msdosfs/denode.h b/sys/msdosfs/denode.h index 14b7ccbab0d..827433ac702 100644 --- a/sys/msdosfs/denode.h +++ b/sys/msdosfs/denode.h @@ -1,4 +1,4 @@ -/* $OpenBSD: denode.h,v 1.17 2004/05/14 04:05:05 tedu Exp $ */ +/* $OpenBSD: denode.h,v 1.18 2005/03/01 14:24:33 tom Exp $ */ /* $NetBSD: denode.h,v 1.24 1997/10/17 11:23:39 ws Exp $ */ /*- @@ -178,6 +178,9 @@ struct denode { */ #define WIN_MAXLEN 255 +/* Maximum size of a file on a FAT filesystem */ +#define MSDOSFS_FILESIZE_MAX 0xFFFFFFFFLL + /* * Transfer directory entries between internal and external form. * dep is a struct denode * (internal form), diff --git a/sys/msdosfs/msdosfs_vnops.c b/sys/msdosfs/msdosfs_vnops.c index 44572722268..9fa6dad1c6a 100644 --- a/sys/msdosfs/msdosfs_vnops.c +++ b/sys/msdosfs/msdosfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: msdosfs_vnops.c,v 1.49 2004/11/30 12:39:43 pedro Exp $ */ +/* $OpenBSD: msdosfs_vnops.c,v 1.50 2005/03/01 14:24:33 tom Exp $ */ /* $NetBSD: msdosfs_vnops.c,v 1.63 1997/10/17 11:24:19 ws Exp $ */ /*- @@ -551,6 +551,10 @@ msdosfs_write(v) if (uio->uio_resid == 0) 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) + return (EFBIG); + /* * If they've exceeded their filesize limit, tell them about it. */ |