qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] contrib/elf2dmp: add ELF dump header checking


From: Richard Henderson
Subject: Re: [PATCH] contrib/elf2dmp: add ELF dump header checking
Date: Thu, 19 May 2022 10:31:26 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0

On 5/19/22 09:48, Viktor Prutyanov wrote:
+    if (ehdr->e_ident[EI_CLASS] != ELFCLASS64 ||
+            ehdr->e_ident[EI_DATA] != ELFDATA2LSB) {
+        eprintf("Invalid ELF class or byte order, must be 64-bit LE\n");
+        return false;
+    }

You could check EI_VERSION == EV_CURRENT too.
You should check e_machine == EM_X86_64.

+    if (!ehdr->e_phnum) {
+        eprintf("Invalid number of ELF program headers\n");
+        return false;
+    }

In init_states(), you appear to assume this number is exactly 1.


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]