From 58bf1340a6274abf75fc37247681577a734768d2 Mon Sep 17 00:00:00 2001 From: jhb Date: Thu, 24 Apr 2003 18:19:19 +0000 Subject: Fail to mount a device if the bytes per sector in the BPB is less than DEV_BSIZE or if the number of FAT sectors is zero. --- sys/fs/msdosfs/msdosfs_vfsops.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'sys/fs/msdosfs') diff --git a/sys/fs/msdosfs/msdosfs_vfsops.c b/sys/fs/msdosfs/msdosfs_vfsops.c index b6ea514..3c5565e 100644 --- a/sys/fs/msdosfs/msdosfs_vfsops.c +++ b/sys/fs/msdosfs/msdosfs_vfsops.c @@ -359,6 +359,10 @@ mountmsdosfs(devvp, mp, td, argp) */ SecPerClust = b50->bpbSecPerClust; pmp->pm_BytesPerSec = getushort(b50->bpbBytesPerSec); + if (pmp->pm_BytesPerSec < DEV_BSIZE) { + error = EINVAL; + goto error_exit; + } pmp->pm_ResSectors = getushort(b50->bpbResSectors); pmp->pm_FATs = b50->bpbFATs; pmp->pm_RootDirEnts = getushort(b50->bpbRootDirEnts); @@ -428,12 +432,14 @@ mountmsdosfs(devvp, mp, td, argp) * - logical sector size: power of 2, >= block size * - sectors per cluster: power of 2, >= 1 * - number of sectors: >= 1, <= size of partition + * - number of FAT sectors: >= 1 */ if ( (SecPerClust == 0) || (SecPerClust & (SecPerClust - 1)) || (pmp->pm_BytesPerSec < DEV_BSIZE) || (pmp->pm_BytesPerSec & (pmp->pm_BytesPerSec - 1)) || (pmp->pm_HugeSectors == 0) + || (pmp->pm_FATsecs == 0) ) { error = EINVAL; goto error_exit; -- cgit v1.1