DragonFlyBSD Kernel Audit
DF-0845 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/vfs/ufs/ufs_dirhash.c b/sys/vfs/ufs/ufs_dirhash.c
--- a/sys/vfs/ufs/ufs_dirhash.c
+++ b/sys/vfs/ufs/ufs_dirhash.c
@@ -129,6 +129,8 @@
 	vp = ip->i_vnode;
 	/* Allocate 50% more entries than this dir size could ever need. */
 	KASSERT(ip->i_size >= DIRBLKSIZ, ("ufsdirhash_build size"));
+	if (ip->i_size > (off_t)0x7fffffff * DIRECTSIZ(1))
+		return (-1);
 	nslots = ip->i_size / DIRECTSIZ(1);
 	nslots = (nslots * 3 + 1) / 2;
 	narrays = howmany(nslots, DH_NBLKOFF);