summaryrefslogtreecommitdiffstats
path: root/lib/libufs/block.c
diff options
context:
space:
mode:
authorjmallett <jmallett@FreeBSD.org>2003-01-19 01:39:53 +0000
committerjmallett <jmallett@FreeBSD.org>2003-01-19 01:39:53 +0000
commit70c14dc49d43fdb49ece8fbd8376b5ad630a84ad (patch)
tree6ae20a9446a1a29fbfa6a350e09eceaf5f224cb1 /lib/libufs/block.c
parent7a4607b5ca601c2df68d7e4186f3eb03cad1bf93 (diff)
downloadFreeBSD-src-70c14dc49d43fdb49ece8fbd8376b5ad630a84ad.zip
FreeBSD-src-70c14dc49d43fdb49ece8fbd8376b5ad630a84ad.tar.gz
Don't crash when utilities are dumb and try to read less than the disk block
size (dumpfs may try to read the cylinder size (or is is sector size?) by way of bread). Prevents a bounds error.
Diffstat (limited to 'lib/libufs/block.c')
-rw-r--r--lib/libufs/block.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/libufs/block.c b/lib/libufs/block.c
index 7586c43..234991a 100644
--- a/lib/libufs/block.c
+++ b/lib/libufs/block.c
@@ -63,7 +63,7 @@ bread(struct uufsd *disk, ufs2_daddr_t blockno, void *data, size_t size)
*/
if (cnt != size) {
ERROR(disk, "short read from block device");
- for (cnt = 0; cnt < disk->d_fs.fs_bsize; cnt++)
+ for (cnt = 0; cnt < MIN(size, disk->d_fs.fs_bsize); cnt++)
buf[cnt] = 0;
return -1;
}
OpenPOWER on IntegriCloud