2006-11-03 Hollis Blanchard <hollis@penguinppc.org>
* kern/elf.c (grub_elf_file): Call grub_file_seek. Call grub_error_push and grub_error_pop in the error-handling path. (grub_elf32_load_segment): Only call grub_file_read with non-zero length.
This commit is contained in:
parent
8b55db6631
commit
ae4f23bfa6
2 changed files with 14 additions and 1 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2006-11-03 Hollis Blanchard <hollis@penguinppc.org>
|
||||||
|
|
||||||
|
* kern/elf.c (grub_elf_file): Call grub_file_seek. Call
|
||||||
|
grub_error_push and grub_error_pop in the error-handling path.
|
||||||
|
(grub_elf32_load_segment): Only call grub_file_read with non-zero
|
||||||
|
length.
|
||||||
|
|
||||||
2006-11-03 Hollis Blanchard <hollis@penguinppc.org>
|
2006-11-03 Hollis Blanchard <hollis@penguinppc.org>
|
||||||
|
|
||||||
* conf/i386-efi.rmk (grub_emu_SOURCES): Add kern/elf.c.
|
* conf/i386-efi.rmk (grub_emu_SOURCES): Add kern/elf.c.
|
||||||
|
|
|
@ -69,6 +69,9 @@ grub_elf_file (grub_file_t file)
|
||||||
elf->file = file;
|
elf->file = file;
|
||||||
elf->phdrs = 0;
|
elf->phdrs = 0;
|
||||||
|
|
||||||
|
if (grub_file_seek (elf->file, 0) == (grub_off_t) -1)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
if (grub_file_read (elf->file, (char *) &elf->ehdr, sizeof (elf->ehdr))
|
if (grub_file_read (elf->file, (char *) &elf->ehdr, sizeof (elf->ehdr))
|
||||||
!= sizeof (elf->ehdr))
|
!= sizeof (elf->ehdr))
|
||||||
{
|
{
|
||||||
|
@ -82,7 +85,9 @@ grub_elf_file (grub_file_t file)
|
||||||
return elf;
|
return elf;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
|
grub_error_push ();
|
||||||
grub_elf_close (elf);
|
grub_elf_close (elf);
|
||||||
|
grub_error_pop ();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +134,8 @@ grub_elf32_load_segment (grub_elf_t elf, Elf32_Phdr *phdr, void *hook)
|
||||||
return grub_error (GRUB_ERR_BAD_OS, "Invalid offset in program header");
|
return grub_error (GRUB_ERR_BAD_OS, "Invalid offset in program header");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (grub_file_read (elf->file, (void *) load_addr, phdr->p_filesz)
|
if (phdr->p_filesz
|
||||||
|
&& grub_file_read (elf->file, (void *) load_addr, phdr->p_filesz)
|
||||||
!= (grub_ssize_t) phdr->p_filesz)
|
!= (grub_ssize_t) phdr->p_filesz)
|
||||||
{
|
{
|
||||||
return grub_error (GRUB_ERR_BAD_OS, "Couldn't load segment");
|
return grub_error (GRUB_ERR_BAD_OS, "Couldn't load segment");
|
||||||
|
|
Loading…
Add table
Reference in a new issue