* grub-core/fs/bfs.c (mount): Improve filesystem detection reliability.

* grub-core/fs/ext2.c (grub_ext2_mount): Likewise.
	* grub-core/fs/hfs.c (grub_hfs_mount): Likewise.
	* grub-core/fs/hfsplus.c (grub_hfsplus_mount): Likewise.
	* grub-core/fs/jfs.c (grub_jfs_mount): Likewise.
	* grub-core/fs/minix.c (grub_minix_mount): Likewise.
	* grub-core/fs/ntfs.c (grub_ntfs_mount): Likewise.
	* grub-core/fs/romfs.c (grub_romfs_mount): Likewise.
	* grub-core/fs/xfs.c (grub_xfs_mount): Likewise.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2012-05-12 13:31:05 +02:00
parent fe8c2f1117
commit 2e57f28fc7
10 changed files with 63 additions and 18 deletions

View file

@ -945,12 +945,18 @@ grub_ntfs_mount (grub_disk_t disk)
if (grub_disk_read (disk, 0, 0, sizeof (bpb), &bpb))
goto fail;
if (grub_memcmp ((char *) &bpb.oem_name, "NTFS", 4))
if (grub_memcmp ((char *) &bpb.oem_name, "NTFS", 4) != 0
|| bpb.sectors_per_cluster == 0
|| (bpb.sectors_per_cluster & (bpb.sectors_per_cluster - 1)) != 0
|| bpb.bytes_per_sector == 0
|| (bpb.bytes_per_sector & (bpb.bytes_per_sector - 1)) != 0)
goto fail;
data->spc = (((grub_uint32_t) bpb.sectors_per_cluster
* (grub_uint32_t) grub_le_to_cpu16 (bpb.bytes_per_sector))
>> GRUB_NTFS_BLK_SHR);
if (!data->spc)
goto fail;
if (bpb.clusters_per_mft > 0)
data->mft_size = data->spc * bpb.clusters_per_mft;