* 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.
This commit is contained in:
Nickolai Zeldovich 2013-03-07 08:52:29 +01:00 committed by Vladimir 'phcoder' Serbinenko
parent e11645f434
commit efd4f11754
2 changed files with 10 additions and 3 deletions

View file

@ -1,3 +1,9 @@
2013-03-07 Nickolai Zeldovich <nickolai@csail.mit.edu>
* 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 <nickolai@csail.mit.edu>
* grub-core/normal/crypto.c (read_crypto_list): Fix incorrect

View file

@ -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;