* grub-core/kern/disk_common.c: Clump disk size to 1EiB.
This commit is contained in:
parent
0af3ae2d8b
commit
d1224d209b
2 changed files with 20 additions and 6 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2014-08-10 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* grub-core/kern/disk_common.c: Clump disk size to 1EiB.
|
||||||
|
|
||||||
2014-08-10 Vladimir Serbinenko <phcoder@gmail.com>
|
2014-08-10 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* grub-core/disk/i386/pc/biosdisk.c (grub_biosdisk_rw): Add
|
* grub-core/disk/i386/pc/biosdisk.c (grub_biosdisk_rw): Add
|
||||||
|
|
|
@ -7,6 +7,8 @@ grub_disk_adjust_range (grub_disk_t disk, grub_disk_addr_t *sector,
|
||||||
grub_off_t *offset, grub_size_t size)
|
grub_off_t *offset, grub_size_t size)
|
||||||
{
|
{
|
||||||
grub_partition_t part;
|
grub_partition_t part;
|
||||||
|
grub_disk_addr_t total_sectors;
|
||||||
|
|
||||||
*sector += *offset >> GRUB_DISK_SECTOR_BITS;
|
*sector += *offset >> GRUB_DISK_SECTOR_BITS;
|
||||||
*offset &= GRUB_DISK_SECTOR_SIZE - 1;
|
*offset &= GRUB_DISK_SECTOR_SIZE - 1;
|
||||||
|
|
||||||
|
@ -27,12 +29,20 @@ grub_disk_adjust_range (grub_disk_t disk, grub_disk_addr_t *sector,
|
||||||
*sector += start;
|
*sector += start;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (disk->total_sectors != GRUB_DISK_SIZE_UNKNOWN
|
/* Transform total_sectors to number of 512B blocks. */
|
||||||
&& ((disk->total_sectors << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS)) <= *sector
|
total_sectors = disk->total_sectors << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS);
|
||||||
|| ((*offset + size + GRUB_DISK_SECTOR_SIZE - 1)
|
|
||||||
>> GRUB_DISK_SECTOR_BITS) > (disk->total_sectors
|
/* Some drivers have problems with disks above reasonable.
|
||||||
<< (disk->log_sector_size
|
Treat unknown as 1EiB disk. While on it, clamp the size to 1EiB.
|
||||||
- GRUB_DISK_SECTOR_BITS)) - *sector))
|
Just one condition is enough since GRUB_DISK_UNKNOWN_SIZE << ls is always
|
||||||
|
above 9EiB.
|
||||||
|
*/
|
||||||
|
if (total_sectors > (1ULL << 51))
|
||||||
|
total_sectors = (1ULL << 51);
|
||||||
|
|
||||||
|
if ((total_sectors <= *sector
|
||||||
|
|| ((*offset + size + GRUB_DISK_SECTOR_SIZE - 1)
|
||||||
|
>> GRUB_DISK_SECTOR_BITS) > total_sectors - *sector))
|
||||||
return grub_error (GRUB_ERR_OUT_OF_RANGE,
|
return grub_error (GRUB_ERR_OUT_OF_RANGE,
|
||||||
N_("attempt to read or write outside of disk `%s'"), disk->name);
|
N_("attempt to read or write outside of disk `%s'"), disk->name);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue