MCPcopy Create free account
hub / github.com/LPC4/Full-Stack / read_u32

Function read_u32

crates/virtual-machine/src/elf_parser.rs:110–118  ·  view source on GitHub ↗

Read a 32-bit little-endian value from bytes at the given offset

(bytes: &[u8], offset: usize)

Source from the content-addressed store, hash-verified

108 .ok_or_else(|| VmError::Other("ELF read overflow".to_owned()))?;
109 let slice = bytes
110 .get(offset..end)
111 .ok_or_else(|| VmError::Other("ELF read out of bounds".to_owned()))?;
112 Ok(u32::from_le_bytes([slice[0], slice[1], slice[2], slice[3]]))
113}
114
115fn read_u64(bytes: &[u8], offset: usize) -> Result<u64, VmError> {
116 let end = offset
117 .checked_add(8)
118 .ok_or_else(|| VmError::Other("ELF read overflow".to_owned()))?;
119 let slice = bytes
120 .get(offset..end)
121 .ok_or_else(|| VmError::Other("ELF read out of bounds".to_owned()))?;

Callers 1

parseMethod · 0.70

Calls 1

getMethod · 0.80

Tested by

no test coverage detected