diff --git a/src/elf.rs b/src/elf.rs index 1be29904..2eb1864f 100644 --- a/src/elf.rs +++ b/src/elf.rs @@ -372,7 +372,12 @@ impl Executable { /// Fully loads an ELF pub fn load(bytes: &[u8], loader: Arc>) -> Result { - let e_flags = LittleEndian::read_u32(bytes.get(48..52).ok_or(ElfParserError::OutOfBounds)?); + const E_FLAGS_OFFSET: usize = 48; + let e_flags = LittleEndian::read_u32( + bytes + .get(E_FLAGS_OFFSET..E_FLAGS_OFFSET.saturating_add(std::mem::size_of::())) + .ok_or(ElfParserError::OutOfBounds)?, + ); let config = loader.get_config(); let sbpf_version = if config.enabled_sbpf_versions.end() == &SBPFVersion::V1 { if e_flags == EF_SBPF_V2 {