grub_ata_setaddress: Check that geometry is sane when using CHS addressing.
This commit is contained in:
parent
1dfe3f973e
commit
f27ccb584c
2 changed files with 11 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* grub-core/disk/ata.c (grub_ata_setaddress): Check that geometry
|
||||||
|
is sane when using CHS addressing.
|
||||||
|
|
||||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* grub-core/disk/AFSplitter.c (AF_merge): Check that mdlen is not 0.
|
* grub-core/disk/AFSplitter.c (AF_merge): Check that mdlen is not 0.
|
||||||
|
|
|
@ -216,6 +216,12 @@ grub_ata_setaddress (struct grub_ata *dev,
|
||||||
unsigned int head;
|
unsigned int head;
|
||||||
unsigned int sect;
|
unsigned int sect;
|
||||||
|
|
||||||
|
if (dev->sectors_per_track == 0
|
||||||
|
|| dev->heads == 0)
|
||||||
|
return grub_error (GRUB_ERR_OUT_OF_RANGE,
|
||||||
|
"sector %d cannot be addressed "
|
||||||
|
"using CHS addressing", sector);
|
||||||
|
|
||||||
/* Calculate the sector, cylinder and head to use. */
|
/* Calculate the sector, cylinder and head to use. */
|
||||||
sect = ((grub_uint32_t) sector % dev->sectors_per_track) + 1;
|
sect = ((grub_uint32_t) sector % dev->sectors_per_track) + 1;
|
||||||
cylinder = (((grub_uint32_t) sector / dev->sectors_per_track)
|
cylinder = (((grub_uint32_t) sector / dev->sectors_per_track)
|
||||||
|
|
Loading…
Reference in a new issue