diff --git a/ChangeLog b/ChangeLog index 0c85b35b4..575bd18be 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-01-20 Vladimir Serbinenko + + * grub-core/disk/ata.c (grub_ata_setaddress): Check that geometry + is sane when using CHS addressing. + 2015-01-20 Vladimir Serbinenko * grub-core/disk/AFSplitter.c (AF_merge): Check that mdlen is not 0. diff --git a/grub-core/disk/ata.c b/grub-core/disk/ata.c index 2b988490f..8ba4e5c50 100644 --- a/grub-core/disk/ata.c +++ b/grub-core/disk/ata.c @@ -216,6 +216,12 @@ grub_ata_setaddress (struct grub_ata *dev, unsigned int head; 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. */ sect = ((grub_uint32_t) sector % dev->sectors_per_track) + 1; cylinder = (((grub_uint32_t) sector / dev->sectors_per_track)