diff options
author | rnordier <rnordier@FreeBSD.org> | 1998-04-20 14:09:40 +0000 |
---|---|---|
committer | rnordier <rnordier@FreeBSD.org> | 1998-04-20 14:09:40 +0000 |
commit | d8a676d94eac455890ffebe9cead1d9842c71fbf (patch) | |
tree | aabc2bc2aa5252798583827d9f96bdfc61bcb458 /sbin | |
parent | 29088df8fe8ad61a03741774fdd7bd150c5bb948 (diff) | |
download | FreeBSD-src-d8a676d94eac455890ffebe9cead1d9842c71fbf.zip FreeBSD-src-d8a676d94eac455890ffebe9cead1d9842c71fbf.tar.gz |
Check bytes read to prevent random error message.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/dumpfs/dumpfs.c | 9 |
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); |