summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Stoeckmann <tobias@cvs.openbsd.org>2014-06-18 17:24:47 +0000
committerTobias Stoeckmann <tobias@cvs.openbsd.org>2014-06-18 17:24:47 +0000
commit97d7ed8e5ab617c099737cd491ed46054dd988e6 (patch)
treecf1cd3d12dac9b10339844a628c1358203913d79
parente6906ccccb928e46ac7ec30657e4b9fcce4e3d38 (diff)
Fix off by one in pm_inusemap.
FreeBSD did this years ago in revision 126086 as pointed out by John-Mark Gurney on tech. Merge it and sync two occurrences. ok krw@
-rw-r--r--sys/msdosfs/msdosfs_fat.c4
-rw-r--r--sys/msdosfs/msdosfs_vfsops.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/sys/msdosfs/msdosfs_fat.c b/sys/msdosfs/msdosfs_fat.c
index a1e13e93b06..2a7877ca327 100644
--- a/sys/msdosfs/msdosfs_fat.c
+++ b/sys/msdosfs/msdosfs_fat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: msdosfs_fat.c,v 1.24 2013/06/11 16:42:16 deraadt Exp $ */
+/* $OpenBSD: msdosfs_fat.c,v 1.25 2014/06/18 17:24:46 tobias Exp $ */
/* $NetBSD: msdosfs_fat.c,v 1.26 1997/10/17 11:24:02 ws Exp $ */
/*-
@@ -866,7 +866,7 @@ fillinusemap(struct msdosfsmount *pmp)
* Mark all clusters in use, we mark the free ones in the fat scan
* loop further down.
*/
- for (cn = 0; cn < (pmp->pm_maxcluster + N_INUSEBITS) / N_INUSEBITS; cn++)
+ for (cn = 0; cn < howmany(pmp->pm_maxcluster + 1, N_INUSEBITS); cn++)
pmp->pm_inusemap[cn] = (u_int)-1;
/*
diff --git a/sys/msdosfs/msdosfs_vfsops.c b/sys/msdosfs/msdosfs_vfsops.c
index 6e5f67b116a..a7d32669466 100644
--- a/sys/msdosfs/msdosfs_vfsops.c
+++ b/sys/msdosfs/msdosfs_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: msdosfs_vfsops.c,v 1.65 2014/05/27 21:52:19 sf Exp $ */
+/* $OpenBSD: msdosfs_vfsops.c,v 1.66 2014/06/18 17:24:46 tobias Exp $ */
/* $NetBSD: msdosfs_vfsops.c,v 1.48 1997/10/18 02:54:57 briggs Exp $ */
/*-
@@ -517,7 +517,7 @@ msdosfs_mountfs(struct vnode *devvp, struct mount *mp, struct proc *p,
* Allocate memory for the bitmap of allocated clusters, and then
* fill it in.
*/
- bmapsiz = (pmp->pm_maxcluster + N_INUSEBITS - 1) / N_INUSEBITS;
+ bmapsiz = howmany(pmp->pm_maxcluster + 1, N_INUSEBITS);
if (bmapsiz == 0 || SIZE_MAX / bmapsiz < sizeof(*pmp->pm_inusemap)) {
/* detect multiplicative integer overflow */
error = EINVAL;