diff options
author | Mike Pechkin <mpech@cvs.openbsd.org> | 2003-10-17 15:08:12 +0000 |
---|---|---|
committer | Mike Pechkin <mpech@cvs.openbsd.org> | 2003-10-17 15:08:12 +0000 |
commit | 50ec88b0da1cbba45ffd7b9fd0645a6e942211c3 (patch) | |
tree | 47052e4e5ff617bac06406d022472fb223dbcdf6 /sys/ufs/ffs | |
parent | b4b88fca02ed03d264249b2a7327e1f462338491 (diff) |
Be sure i_ffs_gen is always positive.
millert@, beck@, tedu@, deraadt@ ok
Diffstat (limited to 'sys/ufs/ffs')
-rw-r--r-- | sys/ufs/ffs/ffs_alloc.c | 6 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_vfsops.c | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c index f285b4dab63..928f024a095 100644 --- a/sys/ufs/ffs/ffs_alloc.c +++ b/sys/ufs/ffs/ffs_alloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_alloc.c,v 1.44 2003/06/02 23:28:22 millert Exp $ */ +/* $OpenBSD: ffs_alloc.c,v 1.45 2003/10/17 15:08:11 mpech Exp $ */ /* $NetBSD: ffs_alloc.c,v 1.11 1996/05/11 18:27:09 mycroft Exp $ */ /* @@ -624,7 +624,7 @@ ffs_inode_alloc(struct inode *pip, int mode, struct ucred *cred, * Need a way to preserve randomization. */ if (ip->i_ffs_gen == 0 || ++(ip->i_ffs_gen) == 0) - ip->i_ffs_gen = arc4random(); + ip->i_ffs_gen = arc4random() & INT_MAX; if (ip->i_ffs_gen == 0 || ip->i_ffs_gen == -1) ip->i_ffs_gen = 1; /* shouldn't happen */ return (0); @@ -669,7 +669,7 @@ ffs_dirpref(pip) * Force allocation in another cg if creating a first level dir. */ if (ITOV(pip)->v_flag & VROOT) { - prefcg = arc4random() % fs->fs_ncg; + prefcg = (arc4random() & INT_MAX) % fs->fs_ncg; mincg = prefcg; minndir = fs->fs_ipg; for (cg = prefcg; cg < fs->fs_ncg; cg++) diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index dcaacc3b195..4d0e448eba8 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.60 2003/10/04 18:47:08 mickey Exp $ */ +/* $OpenBSD: ffs_vfsops.c,v 1.61 2003/10/17 15:08:11 mpech Exp $ */ /* $NetBSD: ffs_vfsops.c,v 1.19 1996/02/09 22:22:26 christos Exp $ */ /* @@ -1232,7 +1232,7 @@ retry: * already have one. This should only happen on old filesystems. */ if (ip->i_ffs_gen == 0) { - ip->i_ffs_gen = arc4random(); + ip->i_ffs_gen = arc4random() & INT_MAX; if (ip->i_ffs_gen == 0 || ip->i_ffs_gen == -1) ip->i_ffs_gen = 1; /* shouldn't happen */ if ((vp->v_mount->mnt_flag & MNT_RDONLY) == 0) |