Author: emaste
Date: Sat Oct 20 18:47:45 2018
New Revision: 339473
URL: https://svnweb.freebsd.org/changeset/base/339473

Log:
  libelf: also test for 64-bit ELF in _libelf_is_mips64el
  
  Although _libelf_is_mips64el is only called in contexts where we've
  already checked that e_class is ELFCLASS64 but this may change in the
  future.  Add a safety belt so that we don't access an invalid e_ehdr64
  union member if it does.
  
  Reported by:  jkoshy (in review D17380)

Modified:
  head/contrib/elftoolchain/libelf/gelf_mips64el.c

Modified: head/contrib/elftoolchain/libelf/gelf_mips64el.c
==============================================================================
--- head/contrib/elftoolchain/libelf/gelf_mips64el.c    Sat Oct 20 18:46:36 
2018        (r339472)
+++ head/contrib/elftoolchain/libelf/gelf_mips64el.c    Sat Oct 20 18:47:45 
2018        (r339473)
@@ -34,7 +34,7 @@ int
 _libelf_is_mips64el(Elf *e)
 {
 
-       return (e->e_kind == ELF_K_ELF &&
+       return (e->e_kind == ELF_K_ELF && e->e_class == ELFCLASS64 &&
            e->e_u.e_elf.e_ehdr.e_ehdr64->e_machine == EM_MIPS &&
            e->e_u.e_elf.e_ehdr.e_ehdr64->e_ident[EI_DATA] == ELFDATA2LSB);
 }
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to