[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] fix null pointer check in grub_acpi_create_ebda
From: |
Nickolai Zeldovich |
Subject: |
[PATCH] fix null pointer check in grub_acpi_create_ebda |
Date: |
Sun, 3 Mar 2013 23:13:21 -0500 (EST) |
User-agent: |
Alpine 2.02 (DEB 1266 2009-07-14) |
The current code in grub_acpi_create_ebda() first computes the ebda
pointer, then dereferences it, and then checks whether the ebda pointer
was null. Several compilers (including gcc) will eliminate null pointer
checks after the pointer has been dereferenced, on the assumption that
the pointer could not be null, since it has already been dereferenced.
The patch below ensures that ebda is dereferenced only if it is non-null.
Nickolai.
---
--- grub-core/commands/acpi.c 2013-01-15 12:02:35 +0000
+++ grub-core/commands/acpi.c 2013-03-04 04:00:58 +0000
@@ -171,7 +171,7 @@
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 @@
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;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] fix null pointer check in grub_acpi_create_ebda,
Nickolai Zeldovich <=