summaryrefslogtreecommitdiffstats
path: root/sbin/dumpfs/dumpfs.c
diff options
context:
space:
mode:
authorrnordier <rnordier@FreeBSD.org>1998-04-20 14:09:40 +0000
committerrnordier <rnordier@FreeBSD.org>1998-04-20 14:09:40 +0000
commitd8a676d94eac455890ffebe9cead1d9842c71fbf (patch)
treeaabc2bc2aa5252798583827d9f96bdfc61bcb458 /sbin/dumpfs/dumpfs.c
parent29088df8fe8ad61a03741774fdd7bd150c5bb948 (diff)
downloadFreeBSD-src-d8a676d94eac455890ffebe9cead1d9842c71fbf.zip
FreeBSD-src-d8a676d94eac455890ffebe9cead1d9842c71fbf.tar.gz
Check bytes read to prevent random error message.
Diffstat (limited to 'sbin/dumpfs/dumpfs.c')
-rw-r--r--sbin/dumpfs/dumpfs.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/sbin/dumpfs/dumpfs.c b/sbin/dumpfs/dumpfs.c
index 28faacf..7216999 100644
--- a/sbin/dumpfs/dumpfs.c
+++ b/sbin/dumpfs/dumpfs.c
@@ -107,15 +107,22 @@ int
dumpfs(name)
char *name;
{
+ ssize_t n;
int fd, c, i, j, k, size;
if ((fd = open(name, O_RDONLY, 0)) < 0)
goto err;
if (lseek(fd, (off_t)SBOFF, SEEK_SET) == (off_t)-1)
goto err;
- if (read(fd, &afs, SBSIZE) != SBSIZE)
+ if ((n = read(fd, &afs, SBSIZE)) == -1)
goto err;
+ if (n != SBSIZE) {
+ warnx("%s: non-existent or truncated superblock, skipped",
+ name);
+ (void)close(fd);
+ return (1);
+ }
if (afs.fs_magic != FS_MAGIC) {
warnx("%s: superblock has bad magic number, skipped", name);
(void)close(fd);
OpenPOWER on IntegriCloud