Module Name:    src
Committed By:   dholland
Date:           Fri Aug 12 08:22:13 UTC 2016

Modified Files:
        src/usr.sbin/dumplfs: dumplfs.c

Log Message:
If the number of inodes per block is zero, bail instead of using
uninitialized stack trash as a dinode pointer. Fixes PR 51409 where
"dumplfs /dev/zero" receives SIGSEGV.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/usr.sbin/dumplfs/dumplfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/dumplfs/dumplfs.c
diff -u src/usr.sbin/dumplfs/dumplfs.c:1.62 src/usr.sbin/dumplfs/dumplfs.c:1.63
--- src/usr.sbin/dumplfs/dumplfs.c:1.62	Wed Jun 15 14:07:54 2016
+++ src/usr.sbin/dumplfs/dumplfs.c	Fri Aug 12 08:22:13 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: dumplfs.c,v 1.62 2016/06/15 14:07:54 riastradh Exp $	*/
+/*	$NetBSD: dumplfs.c,v 1.63 2016/08/12 08:22:13 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 19
 #if 0
 static char sccsid[] = "@(#)dumplfs.c	8.5 (Berkeley) 5/24/95";
 #else
-__RCSID("$NetBSD: dumplfs.c,v 1.62 2016/06/15 14:07:54 riastradh Exp $");
+__RCSID("$NetBSD: dumplfs.c,v 1.63 2016/08/12 08:22:13 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -336,12 +336,19 @@ dump_ifile(int fd, struct lfs *lfsp, int
 		err(1, "malloc");
 	get(fd, fsbtobyte(lfsp, addr), dpage, psize);
 
+	dip = NULL;
 	for (i = LFS_INOPB(lfsp); i-- > 0; ) {
 		dip = DINO_IN_BLOCK(lfsp, dpage, i);
 		if (lfs_dino_getinumber(lfsp, dip) == LFS_IFILE_INUM)
 			break;
 	}
 
+	/* just in case */
+	if (dip == NULL) {
+		warnx("this volume apparently has zero inodes per block");
+		return;
+	}
+
 	if (lfs_dino_getinumber(lfsp, dip) != LFS_IFILE_INUM) {
 		warnx("unable to locate ifile inode at disk address 0x%jx",
 		     (uintmax_t)addr);

Reply via email to