Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/fsck_ffs make sure that we don't try to allocate negati...
details: https://anonhg.NetBSD.org/src/rev/425c9f52d62f
branches: trunk
changeset: 476110:425c9f52d62f
user: christos <christos%NetBSD.org@localhost>
date: Mon Sep 06 19:52:28 1999 +0000
description:
make sure that we don't try to allocate negative memory when blks == 0.
diffstat:
sbin/fsck_ffs/inode.c | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diffs (38 lines):
diff -r 56574790b95f -r 425c9f52d62f sbin/fsck_ffs/inode.c
--- a/sbin/fsck_ffs/inode.c Mon Sep 06 19:01:04 1999 +0000
+++ b/sbin/fsck_ffs/inode.c Mon Sep 06 19:52:28 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: inode.c,v 1.30 1998/10/23 01:13:33 thorpej Exp $ */
+/* $NetBSD: inode.c,v 1.31 1999/09/06 19:52:28 christos Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)inode.c 8.8 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: inode.c,v 1.30 1998/10/23 01:13:33 thorpej Exp $");
+__RCSID("$NetBSD: inode.c,v 1.31 1999/09/06 19:52:28 christos Exp $");
#endif
#endif /* not lint */
@@ -411,13 +411,16 @@
{
struct inoinfo *inp;
struct inoinfo **inpp;
- unsigned int blks;
+ unsigned int blks, extra;
blks = howmany(iswap64(dp->di_size), sblock->fs_bsize);
if (blks > NDADDR)
blks = NDADDR + NIADDR;
- inp = (struct inoinfo *)
- malloc(sizeof(*inp) + (blks - 1) * sizeof(ufs_daddr_t));
+ if (blks > 0)
+ extra = (blks - 1) * sizeof(ufs_daddr_t);
+ else
+ extra = 0;
+ inp = (struct inoinfo *) malloc(sizeof(*inp) + extra);
if (inp == NULL)
return;
inpp = &inphead[inumber % numdirs];
Home |
Main Index |
Thread Index |
Old Index