From giles@topaz.nemeton.com.au  Sun Sep  8 17:39:29 1996
Received: from perki0.connect.com.au (perki0.connect.com.au [192.189.54.85])
          by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id RAA07968
          for <FreeBSD-gnats-submit@freebsd.org>; Sun, 8 Sep 1996 17:39:27 -0700 (PDT)
Received: (from Unemeton@localhost) by perki0.connect.com.au id KAA06737
  (8.7.5/IDA-1.6 for FreeBSD-gnats-submit@freebsd.org); Mon, 9 Sep 1996 10:39:15 +1000 (EST)
Message-Id: <199609090040.KAA00376@topaz.nemeton.com.au>
Date: Mon, 9 Sep 1996 10:40:25 +1000 (EST)
From: Giles Lean <giles@nemeton.com.au>
Reply-To: giles@nemeton.com.au
To: FreeBSD-gnats-submit@freebsd.org
Subject: dumpfs can dump core
X-Send-Pr-Version: 3.2

>Number:         1585
>Category:       bin
>Synopsis:       dumpfs can dump core
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Sep  8 17:40:01 PDT 1996
>Closed-Date:    Mon Oct 21 12:40:15 PDT 1996
>Last-Modified:  Mon Oct 21 12:40:36 PDT 1996
>Originator:     Giles Lean
>Release:        FreeBSD 2.2-CURRENT i386
>Organization:
>Environment:

	2.2-current

>Description:

	dumpfs blindly trusts that it is working on a filesystem.

>How-To-Repeat:

	(No filesystem creaed on /dev/rsd1e)

	# dumpfs /dev/rsd1e
	magic   0       time    Thu Jan  1 10:00:00 1970
	cylgrp  dynamic inodes  4.2/4.3BSD
	nbfree  0       ndir    0       nifree  0       nffree  0
	ncg     0       ncyl    0       size    0       blocks  0
	bsize   0       shift   0       mask    0x00000000
	fsize   0       shift   0       mask    0x00000000
	frag    0       shift   0       fsbtodb 0
	Floating point exception (core dumped)
	# 

>Fix:
	Test for FS_MAGIC.

	This fix is taken from NetBSD PR bin/249, closed in December
	1994.  (Am I the only person in the world who uses dumpfs
	on the wrong partition? :)

--- dumpfs.c-old	Mon Sep  9 10:26:30 1996
+++ dumpfs.c	Mon Sep  9 10:30:22 1996
@@ -47,6 +47,7 @@
 #include <ufs/ufs/dinode.h>
 #include <ufs/ffs/fs.h>
 
+#include <err.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <errno.h>
@@ -114,6 +115,13 @@
 		goto err;
 	if (read(fd, &afs, SBSIZE) != SBSIZE)
 		goto err;
+
+ 	if (afs.fs_magic != FS_MAGIC) {
+		warnx("%s: superblock has bad magic number, skipping.",
+		     name);
+		(void) close(fd);
+ 		return (1);
+ 	}
 
 	if (afs.fs_postblformat == FS_42POSTBLFMT)
 		afs.fs_nrpos = 8;

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: phk 
State-Changed-When: Mon Oct 21 12:40:15 PDT 1996 
State-Changed-Why:  
done 
>Unformatted:
