summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiklas Hallqvist <niklas@cvs.openbsd.org>1997-10-11 20:19:37 +0000
committerNiklas Hallqvist <niklas@cvs.openbsd.org>1997-10-11 20:19:37 +0000
commit3cb264a844ab837e956062cf75bdc9ae06cc4265 (patch)
treedb7e32e68508bfbe87d3a04fa50416f2061d049a
parent4f6839016b6807d89cb76312fd9bec85d136da5f (diff)
Never involve negative numbers in unsigned expressions. Fixes a segfault some
bad fs images triggers.
-rw-r--r--sbin/fsck_ffs/inode.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sbin/fsck_ffs/inode.c b/sbin/fsck_ffs/inode.c
index 9324b60dab9..cabe02a368e 100644
--- a/sbin/fsck_ffs/inode.c
+++ b/sbin/fsck_ffs/inode.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: inode.c,v 1.12 1997/10/06 20:22:32 deraadt Exp $ */
+/* $OpenBSD: inode.c,v 1.13 1997/10/11 20:19:36 niklas Exp $ */
/* $NetBSD: inode.c,v 1.23 1996/10/11 20:15:47 thorpej Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)inode.c 8.5 (Berkeley) 2/8/95";
#else
-static char rcsid[] = "$OpenBSD: inode.c,v 1.12 1997/10/06 20:22:32 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: inode.c,v 1.13 1997/10/11 20:19:36 niklas Exp $";
#endif
#endif /* not lint */
@@ -384,7 +384,7 @@ cacheino(dp, inumber)
if (blks > NDADDR)
blks = NDADDR + NIADDR;
inp = (struct inoinfo *)
- malloc(sizeof(*inp) + (blks - 1) * sizeof(daddr_t));
+ malloc(sizeof(*inp) + (blks ? blks - 1 : 0) * sizeof(daddr_t));
if (inp == NULL)
return;
inpp = &inphead[inumber % numdirs];