:: commit 792dc81b43cb1b5a2c29ce01b1f49146c4ee3cf7

mintsuki <mintsuki@protonmail.com> — 2021-11-10 11:29

parents: 286f3bc62d

bootboot: Check for the right architecture when bruteforcing kernel (see #124)

diff --git a/stage23/protos/bootboot/initrd.c b/stage23/protos/bootboot/initrd.c
index 387c7de0..efef3387 100644
--- a/stage23/protos/bootboot/initrd.c
+++ b/stage23/protos/bootboot/initrd.c
@@ -8,7 +8,8 @@
 
 struct initrd_file bruteforce_kernel(struct initrd_file file) {
     for (size_t i = 0; i < file.size; i++) {
-        if (memcmp(file.data + i, "\177ELF", 4) == 0) {
+        if (memcmp(file.data + i, "\177ELF", 4) == 0
+         && file.data[i + 18] == 62 && file.data[i + 19] == 0 /* ehdr->e_machine == EM_X86_64 */) {
             printv("bootboot: using bruteforced kernel at initrd offset %X\n", file.data + i);
             return (struct initrd_file){
                 .size = file.size - i,
tab: 248 wrap: offon