From 821c03bf9fa130389cd4e05fb44de8095945408f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Mei=C3=9Fner?= Date: Thu, 14 Nov 2024 19:37:31 +0100 Subject: [PATCH] Documents E_FLAGS_OFFSET. --- src/elf.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 {