Compare ELFMAGIC bits as a byte slice
This commit is contained in:
parent
aff2d776ee
commit
8373835dd8
@ -38,6 +38,7 @@ pub const ELFMAG1: u8 = 0x45;
|
||||
pub const ELFMAG2: u8 = 0x4c;
|
||||
/// ELF magic number byte 4
|
||||
pub const ELFMAG3: u8 = 0x46;
|
||||
pub const ELFMAGIC: [u8; 4] = [ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3];
|
||||
|
||||
/// ELFCLASS* define constants for e_ident[EI_CLASS]
|
||||
|
||||
|
@ -75,8 +75,7 @@ impl File {
|
||||
}
|
||||
|
||||
// Verify the magic number
|
||||
if ident[0] != gabi::ELFMAG0 || ident[1] != gabi::ELFMAG1
|
||||
|| ident[2] != gabi::ELFMAG2 || ident[3] != gabi::ELFMAG3 {
|
||||
if ident.split_at(gabi::EI_CLASS).0 != gabi::ELFMAGIC {
|
||||
return Err(ParseError::InvalidMagic);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user