Hi!

> Changes in src/sys/lib/libsa:
>    cvs rdiff -r1.2 -r1.3 src/sys/lib/libsa/loadfile.c
>    cvs rdiff -r1.3 -r1.4 src/sys/lib/libsa/loadfile_elf.c
> Log message:
> more strict elf header checking to prevent wrong arch kernels being booted 
> and producing confusing errors

I presume that it was kind of mistyping as no one is currently
checking 64-bit builds since has more important tasks.
elf32 field of union hdr will never defined on 64bit builds.

Right fix should be:

===================================================================
RCS file: /data/anoncvs/AerieBSD/src/sys/lib/libsa/loadfile.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- src/sys/lib/libsa/loadfile.c        2008/12/26 18:51:51     1.2
+++ src/sys/lib/libsa/loadfile.c        2009/12/10 12:15:12     1.3
@@ -149,12 +149,14 @@
 #endif
 #if defined(BOOT_ELF32) || (defined(BOOT_ELF) && ELFSIZE == 32)
        if (memcmp(hdr.elf32.e_ident, ELFMAG, SELFMAG) == 0 &&
+           hdr.elf32.e_ident[EI_DATA] == ELF_TARG_DATA &&
            hdr.elf32.e_ident[EI_CLASS] == ELFCLASS32) {
                rval = elf32_exec(fd, &hdr.elf32, marks, flags);
        } else
 #endif
 #if defined(BOOT_ELF64) || (defined(BOOT_ELF) && ELFSIZE == 64)
        if (memcmp(hdr.elf64.e_ident, ELFMAG, SELFMAG) == 0 &&
+           hdr.elf64.e_ident[EI_DATA] == ELF_TARG_DATA &&
            hdr.elf64.e_ident[EI_CLASS] == ELFCLASS64) {
                rval = elf64_exec(fd, &hdr.elf64, marks, flags);
        } else

Reply via email to