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
This commit is contained in:
Poul-Henning Kamp 1996-10-21 19:40:01 +00:00
parent 04eaedf23d
commit c650708207

View File

@ -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);