2008-09-08 Robert Millan <rmh@aybabtu.com>
* loader/i386/pc/multiboot.c (grub_multiboot_load_elf32): Skip segments when their filesz is zero (grub_file_read() interprets zero-size as "read untill EOF", which results in memory corruption). Use `lowest_segment' rather than 0 for calculating the current segment load address.
This commit is contained in:
parent
40da438f10
commit
89d5ffcfd1
2 changed files with 11 additions and 3 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2008-09-08 Robert Millan <rmh@aybabtu.com>
|
||||||
|
|
||||||
|
* loader/i386/pc/multiboot.c (grub_multiboot_load_elf32): Skip
|
||||||
|
segments when their filesz is zero (grub_file_read() interprets
|
||||||
|
zero-size as "read untill EOF", which results in memory corruption).
|
||||||
|
Use `lowest_segment' rather than 0 for calculating the current
|
||||||
|
segment load address.
|
||||||
|
|
||||||
2008-09-08 Robert Millan <rmh@aybabtu.com>
|
2008-09-08 Robert Millan <rmh@aybabtu.com>
|
||||||
|
|
||||||
* util/hostdisk.c (open_device): Replace a grub_util_info() call
|
* util/hostdisk.c (open_device): Replace a grub_util_info() call
|
||||||
|
|
|
@ -158,7 +158,7 @@ grub_multiboot_load_elf32 (grub_file_t file, void *buffer)
|
||||||
#define phdr(i) ((Elf32_Phdr *) (phdr_base + (i) * ehdr->e_phentsize))
|
#define phdr(i) ((Elf32_Phdr *) (phdr_base + (i) * ehdr->e_phentsize))
|
||||||
|
|
||||||
for (i = 0; i < ehdr->e_phnum; i++)
|
for (i = 0; i < ehdr->e_phnum; i++)
|
||||||
if (phdr(i)->p_type == PT_LOAD)
|
if (phdr(i)->p_type == PT_LOAD && phdr(i)->p_filesz != 0)
|
||||||
{
|
{
|
||||||
if (phdr(i)->p_paddr < phdr(lowest_segment)->p_paddr)
|
if (phdr(i)->p_paddr < phdr(lowest_segment)->p_paddr)
|
||||||
lowest_segment = i;
|
lowest_segment = i;
|
||||||
|
@ -177,9 +177,9 @@ grub_multiboot_load_elf32 (grub_file_t file, void *buffer)
|
||||||
/* Load every loadable segment in memory. */
|
/* Load every loadable segment in memory. */
|
||||||
for (i = 0; i < ehdr->e_phnum; i++)
|
for (i = 0; i < ehdr->e_phnum; i++)
|
||||||
{
|
{
|
||||||
if (phdr(i)->p_type == PT_LOAD)
|
if (phdr(i)->p_type == PT_LOAD && phdr(i)->p_filesz != 0)
|
||||||
{
|
{
|
||||||
char *load_this_module_at = (char *) (grub_multiboot_payload_orig + (phdr(i)->p_paddr - phdr(0)->p_paddr));
|
char *load_this_module_at = (char *) (grub_multiboot_payload_orig + (phdr(i)->p_paddr - phdr(lowest_segment)->p_paddr));
|
||||||
|
|
||||||
grub_dprintf ("multiboot_loader", "segment %d: paddr=%p, memsz=0x%x\n",
|
grub_dprintf ("multiboot_loader", "segment %d: paddr=%p, memsz=0x%x\n",
|
||||||
i, (void *) phdr(i)->p_paddr, phdr(i)->p_memsz);
|
i, (void *) phdr(i)->p_paddr, phdr(i)->p_memsz);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue