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

This commit is contained in:
mintsuki 2021-11-10 12:29:58 +01:00
parent e0fefcf21c
commit 6aba8decc4

View File

@ -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,