diff --git a/ChangeLog b/ChangeLog index ca3d603d9..5fb9b77ab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2013-03-07 Nickolai Zeldovich + + * grub-core/commands/acpi.c (grub_acpi_create_ebda): Don't + dereference null pointer. While the code is technically correct, gcc + may eliminate a null check if pointer is already dereferenced. + 2013-03-07 Nickolai Zeldovich * grub-core/normal/crypto.c (read_crypto_list): Fix incorrect diff --git a/grub-core/commands/acpi.c b/grub-core/commands/acpi.c index 891e392a5..800087311 100644 --- a/grub-core/commands/acpi.c +++ b/grub-core/commands/acpi.c @@ -171,7 +171,7 @@ grub_acpi_create_ebda (void) struct grub_acpi_create_ebda_ctx ctx = { .highestlow = 0 }; - int ebda_kb_len; + int ebda_kb_len = 0; int mmapregion = 0; grub_uint8_t *ebda, *v1inebda = 0, *v2inebda = 0; grub_uint8_t *targetebda, *target; @@ -179,8 +179,9 @@ grub_acpi_create_ebda (void) struct grub_acpi_rsdp_v20 *v2; ebda = (grub_uint8_t *) (grub_addr_t) ((*((grub_uint16_t *)0x40e)) << 4); - ebda_kb_len = *(grub_uint16_t *) ebda; - if (! ebda || ebda_kb_len > 16) + if (ebda) + ebda_kb_len = *(grub_uint16_t *) ebda; + if (ebda_kb_len > 16) ebda_kb_len = 0; ctx.ebda_len = (ebda_kb_len + 1) << 10;