summaryrefslogtreecommitdiff
path: root/sys/ufs
diff options
context:
space:
mode:
authornatano <natano@cvs.openbsd.org>2016-02-26 08:56:11 +0000
committernatano <natano@cvs.openbsd.org>2016-02-26 08:56:11 +0000
commitaf60aaf068bc74837ccf13dd9e83acb1b914312d (patch)
tree108b66de4f5e53c0357f6b2d9d44c4e73f2e45cc /sys/ufs
parente4d284802c8ed9482f05c1d555f4e627068b41a4 (diff)
Convert mnt_maxsymlinklen to unsigned.
This allows to remove some truncating casts in symlink handling code. Also, validate fs_maxsymlinklen in the superblock at mount time and on fsck to make sure we don't use bogus data. discussion & ok millert@, stefan@
Diffstat (limited to 'sys/ufs')
-rw-r--r--sys/ufs/ext2fs/ext2fs_readwrite.c4
-rw-r--r--sys/ufs/ext2fs/ext2fs_vnops.c4
-rw-r--r--sys/ufs/ffs/ffs_vfsops.c7
-rw-r--r--sys/ufs/ffs/ffs_vnops.c4
4 files changed, 12 insertions, 7 deletions
diff --git a/sys/ufs/ext2fs/ext2fs_readwrite.c b/sys/ufs/ext2fs/ext2fs_readwrite.c
index 33cbcef0d1f..f836bee528b 100644
--- a/sys/ufs/ext2fs/ext2fs_readwrite.c
+++ b/sys/ufs/ext2fs/ext2fs_readwrite.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ext2fs_readwrite.c,v 1.37 2016/02/16 17:56:12 stefan Exp $ */
+/* $OpenBSD: ext2fs_readwrite.c,v 1.38 2016/02/26 08:56:10 natano Exp $ */
/* $NetBSD: ext2fs_readwrite.c,v 1.16 2001/02/27 04:37:47 chs Exp $ */
/*-
@@ -95,7 +95,7 @@ ext2_ind_read(struct vnode *vp, struct inode *ip, struct m_ext2fs *fs,
panic("%s: mode", "ext2fs_read");
if (vp->v_type == VLNK) {
- if ((int)ext2fs_size(ip) < vp->v_mount->mnt_maxsymlinklen ||
+ if (ext2fs_size(ip) < vp->v_mount->mnt_maxsymlinklen ||
(vp->v_mount->mnt_maxsymlinklen == 0 &&
ip->i_e2fs_nblock == 0))
panic("%s: short symlink", "ext2fs_read");
diff --git a/sys/ufs/ext2fs/ext2fs_vnops.c b/sys/ufs/ext2fs/ext2fs_vnops.c
index 364b083ef52..1c39a2b61b8 100644
--- a/sys/ufs/ext2fs/ext2fs_vnops.c
+++ b/sys/ufs/ext2fs/ext2fs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ext2fs_vnops.c,v 1.74 2016/02/16 17:56:12 stefan Exp $ */
+/* $OpenBSD: ext2fs_vnops.c,v 1.75 2016/02/26 08:56:10 natano Exp $ */
/* $NetBSD: ext2fs_vnops.c,v 1.1 1997/06/11 09:34:09 bouyer Exp $ */
/*
@@ -322,7 +322,7 @@ ext2fs_setattr(void *v)
if (vap->va_mode != (mode_t)VNOVAL) {
if (vp->v_mount->mnt_flag & MNT_RDONLY)
return (EROFS);
- error = ext2fs_chmod(vp, (int)vap->va_mode, cred, p);
+ error = ext2fs_chmod(vp, vap->va_mode, cred, p);
}
return (error);
}
diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c
index 3af23ab49ae..530d66368a5 100644
--- a/sys/ufs/ffs/ffs_vfsops.c
+++ b/sys/ufs/ffs/ffs_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ffs_vfsops.c,v 1.150 2016/01/12 11:41:00 mpi Exp $ */
+/* $OpenBSD: ffs_vfsops.c,v 1.151 2016/02/26 08:56:10 natano Exp $ */
/* $NetBSD: ffs_vfsops.c,v 1.19 1996/02/09 22:22:26 christos Exp $ */
/*
@@ -642,6 +642,11 @@ ffs_validate(struct fs *fsp)
if ((u_int)fsp->fs_frag > MAXFRAG || fragtbl[fsp->fs_frag] == NULL)
return (0); /* Invalid number of fragments */
+ if (fsp->fs_inodefmt == FS_42INODEFMT)
+ fsp->fs_maxsymlinklen = 0;
+ else if (fsp->fs_maxsymlinklen < 0)
+ return (0); /* Invalid max size of short symlink */
+
return (1); /* Super block is okay */
}
diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c
index 9673f3c61da..64d50aa615d 100644
--- a/sys/ufs/ffs/ffs_vnops.c
+++ b/sys/ufs/ffs/ffs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ffs_vnops.c,v 1.82 2016/02/16 17:56:12 stefan Exp $ */
+/* $OpenBSD: ffs_vnops.c,v 1.83 2016/02/26 08:56:10 natano Exp $ */
/* $NetBSD: ffs_vnops.c,v 1.7 1996/05/11 18:27:24 mycroft Exp $ */
/*
@@ -207,7 +207,7 @@ ffs_read(void *v)
panic("ffs_read: mode");
if (vp->v_type == VLNK) {
- if ((int)DIP(ip, size) < vp->v_mount->mnt_maxsymlinklen ||
+ if (DIP(ip, size) < vp->v_mount->mnt_maxsymlinklen ||
(vp->v_mount->mnt_maxsymlinklen == 0 &&
DIP(ip, blocks) == 0))
panic("ffs_read: short symlink");