It isn't an error for an elf executable to be lacking a section header table. In this case we should just be returning shnum = 0.
According to the elf(5) manual page: " e_shoff This member holds the section header table's file offset in bytes. If the file has no section header table, this member holds zero. " Signed-off-by: Mathieu Mirmont <m...@neutrality.ch> --- grub-core/kern/elfXX.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grub-core/kern/elfXX.c b/grub-core/kern/elfXX.c index aabf4b9d7..fe4ffb261 100644 --- a/grub-core/kern/elfXX.c +++ b/grub-core/kern/elfXX.c@@ -220,12 +220,12 @@ grub_elfXX_get_shnum (ElfXX_Ehdr *e, ElfXX_Shnum *shnum)
if (e == NULL)return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("NULL pointer passed for elf header"));
+ if (e->e_shoff == 0) + return GRUB_ERR_NONE; + *shnum = e->e_shnum; if (*shnum == SHN_UNDEF) { - if (e->e_shoff == 0) -return grub_error (GRUB_ERR_BAD_NUMBER, N_("invalid section header table offset in e_shoff"));
- s = (ElfXX_Shdr *) ((grub_uint8_t *) e + e->e_shoff); *shnum = s->sh_size; if (*shnum < SHN_LORESERVE) -- 2.30.2
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel