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.
This commit is contained in:
Juli Mallett 2003-01-19 01:39:53 +00:00
parent a778dc9ca5
commit e3e8d2ca45
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=109511

View File

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