From 1780efae07f7f4f9b03f98aed330fb41bb11d3d2 Mon Sep 17 00:00:00 2001 From: Marc Hartmayer Date: Mon, 15 Nov 2021 11:02:33 +0100 Subject: [PATCH] zdump: df_elf: ehdr_is_elf_object: add ELF version check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, only the ELF version `1` is defined by the ELF specification. See `man 5 elf` for details. Therefore of course, we do only support this version. Signed-off-by: Marc Hartmayer Reviewed-by: Alexander Egorenkov Reviewed-by: Steffen Eiden Signed-off-by: Jan Höppner --- zdump/df_elf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zdump/df_elf.c b/zdump/df_elf.c index 8837ef76..a1780e21 100644 --- a/zdump/df_elf.c +++ b/zdump/df_elf.c @@ -38,7 +38,7 @@ void *ehdr_init(Elf64_Ehdr *ehdr, Elf64_Half phnum) bool ehdr_is_elf_object(const Elf64_Ehdr *ehdr) { - return (memcmp(ehdr->e_ident, ELFMAG, SELFMAG) == 0); + return (ehdr->e_version == ELF_VERSION_1) && (memcmp(ehdr->e_ident, ELFMAG, SELFMAG) == 0); } bool ehdr_is_vmcore(const Elf64_Ehdr *ehdr)