> I found a few bugs in the grub-file utility and the corresponding > command.
The last bug I found is that a null pointer dereference can happen in the knetbsd tests when the tested file doesn't have a valid ELF header. Greetings Lukas Fink >From a2533eac007b1e50c1c8ef2acc36b44e08a9fbc1 Mon Sep 17 00:00:00 2001 From: Lukas Fink <lukas.fi...@gmail.com> Date: Sun, 30 Aug 2020 01:00:10 +0200 Subject: [PATCH 3/3] commands/file: Fix possible null dereference that happened in the knetbsd tests, when grub_elf_file returned null on the given file. This occured for example when the file had no valid elf header. --- grub-core/commands/file.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/commands/file.c b/grub-core/commands/file.c index 2c4718cb2..18ecdc6f2 100644 --- a/grub-core/commands/file.c +++ b/grub-core/commands/file.c @@ -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) + break; if (elf->ehdr.ehdr32.e_type != grub_cpu_to_le16_compile_time (ET_EXEC) || elf->ehdr.ehdr32.e_ident[EI_DATA] != ELFDATA2LSB) break; -- 2.28.0