commands/file: Fix null dereference in the knetbsd tests
PATCH 1/1 commands/file: Fix null dereference in the knetbsd tests
From: Lukas Fink <[email protected]>
The pointer returned by grub_elf_file() is not checked to verify it is not null before use. A null pointer may be returned when the given file does not have a valid ELF header.
--- grub-core/commands/file.c | 2 ++ 1 file changed, 2 insertions(+)
grub-core/commands/file.c +2 -0
@@ -306,6 +306,8 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args) elf =grub_elf_file (file, file->name); +if (elf ==NULL ) +break ;if (elf->ehdr.ehdr32.e_type !=grub_cpu_to_le16_compile_time (ET_EXEC ) || elf->ehdr.ehdr32.e_ident[EI_DATA ] !=ELFDATA2LSB )break ;
Signature · 7 lines
2.34.1 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 5 lines · Glenn Washburn
From: Lukas Fink <[email protected]>
The pointer returned by
grub_elf_file()is not checked to verify it is not null before use. A null pointer may be returned when the given file does not have a valid ELF header.
Indeed or for a number of other reasons. Also other places in the switch check if elf == NULL.
Quoted 13 lines
Signed-off-by Lukas Fink <[email protected]>Signed-off-by Glenn Washburn <[email protected]>--- grub-core/commands/file.c | 2 ++ 1 file changed, 2 insertions(+)grub-core/commands/file.c +0
-0
grub-core/commands/file.c grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args) · line 313
Quoted 8 lines
grub-core/commands/file.c +2
-0@@ -306,6 +306,8 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args) elf =grub_elf_file (file, file->name); +if (elf ==NULL ) +break ;if (elf->ehdr.ehdr32.e_type !=grub_cpu_to_le16_compile_time (ET_EXEC ) || elf->ehdr.ehdr32.e_ident[EI_DATA ] !=ELFDATA2LSB )break ;
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Daniel Kiper
Reviewed-byQuoted 11 lines · Ross Philipson via Grub-devel
Quoted 5 lines · Glenn Washburn
From: Lukas Fink <[email protected]>
The pointer returned by
grub_elf_file()is not checked to verify it is not null before use. A null pointer may be returned when the given file does not have a valid ELF header.Indeed or for a number of other reasons. Also other places in the switch check if elf == NULL.
Reviewed-by Ross Philipson <[email protected]>
Daniel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel