diff options
author | dg <dg@FreeBSD.org> | 1994-10-22 02:27:35 +0000 |
---|---|---|
committer | dg <dg@FreeBSD.org> | 1994-10-22 02:27:35 +0000 |
commit | dd9d06bd3f5bc84ffb6a3a4f440c89da30ef4267 (patch) | |
tree | e2154adabd1dbdbb10ca9ab8f3c4f45ff8fe3674 | |
parent | 4d06675bdc1e27111fe0fd9ef02912b2aaf41260 (diff) | |
download | FreeBSD-src-dd9d06bd3f5bc84ffb6a3a4f440c89da30ef4267.zip FreeBSD-src-dd9d06bd3f5bc84ffb6a3a4f440c89da30ef4267.tar.gz |
Restrict fs_maxfilesize to 2^40, and check against this in ffs_truncate().
This is part of a bug fix from Kirk McKusick to work around problems in FFS
related to the blkno of a 64bit offset not fitting into an int. Note the
proper solution would be to deal with 64bit block numbers, but doing this
would require sweeping changes; some other day perhaps.
Submitted by: Marshall Kirk McKusick
-rw-r--r-- | sys/ufs/ffs/ffs_inode.c | 8 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_vfsops.c | 5 |
2 files changed, 8 insertions, 5 deletions
diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c index defa2e8..8987383 100644 --- a/sys/ufs/ffs/ffs_inode.c +++ b/sys/ufs/ffs/ffs_inode.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)ffs_inode.c 8.5 (Berkeley) 12/30/93 - * $Id: ffs_inode.c,v 1.7 1994/09/02 10:24:55 davidg Exp $ + * $Id: ffs_inode.c,v 1.8 1994/10/10 01:04:37 phk Exp $ */ #include <sys/param.h> @@ -163,9 +163,10 @@ ffs_truncate(ap) int aflags, error, allerror; off_t osize; - if (length < 0) - panic("ffs_truncate: invalid length"); oip = VTOI(ovp); + fs = oip->i_fs; + if (length < 0 || length > fs->fs_maxfilesize) + return (EINVAL); tv = time; if (ovp->v_type == VLNK && (oip->i_size < ovp->v_mount->mnt_maxsymlinklen || oip->i_din.di_blocks == 0)) { @@ -188,7 +189,6 @@ ffs_truncate(ap) return (error); #endif vnode_pager_setsize(ovp, (u_long)length); - fs = oip->i_fs; osize = oip->i_size; /* * Lengthen the size of the file. We must ensure that the diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 73c8c0b..ad3231f 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)ffs_vfsops.c 8.8 (Berkeley) 4/18/94 - * $Id: ffs_vfsops.c,v 1.8 1994/10/08 06:20:06 phk Exp $ + * $Id: ffs_vfsops.c,v 1.9 1994/10/10 01:04:39 phk Exp $ */ #include <sys/param.h> @@ -490,11 +490,14 @@ ffs_oldfscompat(fs) if (fs->fs_inodefmt < FS_44INODEFMT) { /* XXX */ quad_t sizepb = fs->fs_bsize; /* XXX */ /* XXX */ +#if 0 fs->fs_maxfilesize = fs->fs_bsize * NDADDR - 1; /* XXX */ for (i = 0; i < NIADDR; i++) { /* XXX */ sizepb *= NINDIR(fs); /* XXX */ fs->fs_maxfilesize += sizepb; /* XXX */ } /* XXX */ +#endif + fs->fs_maxfilesize = (u_quad_t) 1 << 39; fs->fs_qbmask = ~fs->fs_bmask; /* XXX */ fs->fs_qfmask = ~fs->fs_fmask; /* XXX */ } /* XXX */ |