ntfs_boot_sector_parse: check sectors value & last sector seekability

master
szaka 2006-12-09 00:02:45 +00:00
parent 45630fa43c
commit 2bc71e4ee7
1 changed files with 13 additions and 0 deletions

View File

@ -208,6 +208,19 @@ int ntfs_boot_sector_parse(ntfs_volume *vol, const NTFS_BOOT_SECTOR *bs)
sectors = sle64_to_cpu(bs->number_of_sectors);
ntfs_log_debug("NumberOfSectors = %lld\n", sectors);
if (!sectors) {
ntfs_log_error("Volume size is set to zero.\n");
return -1;
}
if (vol->dev->d_ops->seek(vol->dev,
(sectors - 1) << vol->sector_size_bits,
SEEK_SET) == -1) {
ntfs_log_perror("Failed to read last sector (%lld)", sectors);
ntfs_log_error("Perhaps the volume is a RAID/LDM but it wasn't "
"setup yet, or the\nwrong device was used, "
"or the partition table is incorrect.\n" );
return -1;
}
vol->nr_clusters = sectors >> (ffs(sectors_per_cluster) - 1);