summaryrefslogtreecommitdiffstats
path: root/sbin/dumpfs
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1996-10-21 19:40:01 +0000
committerphk <phk@FreeBSD.org>1996-10-21 19:40:01 +0000
commitb6475895358f64f460bc7b240ea116e28efe0355 (patch)
tree18e423f667ae7704fe4f82d8d1af09110943075c /sbin/dumpfs
parent4256f5443cf3efbd469bb0c867d7d28d40133a99 (diff)
downloadFreeBSD-src-b6475895358f64f460bc7b240ea116e28efe0355.zip
FreeBSD-src-b6475895358f64f460bc7b240ea116e28efe0355.tar.gz
dumpfs blindly trusts that it has been handed a filesystem.
If the magic is bad, don't waste our time. Submitted by: Giles Lean Giles Lean <giles@nemeton.com.au> Obtained from: NetBSD PR bin/249
Diffstat (limited to 'sbin/dumpfs')
-rw-r--r--sbin/dumpfs/dumpfs.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/sbin/dumpfs/dumpfs.c b/sbin/dumpfs/dumpfs.c
index 34b0674..bcde08a 100644
--- a/sbin/dumpfs/dumpfs.c
+++ b/sbin/dumpfs/dumpfs.c
@@ -115,6 +115,13 @@ dumpfs(name)
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;
dev_bsize = afs.fs_fsize / fsbtodb(&afs, 1);
OpenPOWER on IntegriCloud