From 35c5a3ca61dc2655833afafb36cbd31f85202939 Mon Sep 17 00:00:00 2001 From: Erica Marigold Date: Fri, 5 Jan 2024 17:27:50 +0530 Subject: [PATCH] fix: use fixed (little) endianness --- src/cli/build.rs | 6 +++--- src/executor.rs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cli/build.rs b/src/cli/build.rs index 156191a..7bbbfc3 100644 --- a/src/cli/build.rs +++ b/src/cli/build.rs @@ -48,11 +48,11 @@ pub async fn build_standalone>( patched_bin.extend(&bytecode); - let mut meta = base_bin_offset.to_ne_bytes().to_vec(); // Start with the base bytecode offset + let mut meta = base_bin_offset.to_le_bytes().to_vec(); // Start with the base bytecode offset // Include metadata in the META chunk, each field is 8 bytes - meta.extend((bytecode.len() as u64).to_ne_bytes()); // Size of bytecode, used to calculate end offset at runtime - meta.extend(1_u64.to_ne_bytes()); // Number of files, padded with null bytes - for future use + meta.extend((bytecode.len() as u64).to_le_bytes()); // Size of bytecode, used to calculate end offset at runtime + meta.extend(1_u64.to_le_bytes()); // Number of files, padded with null bytes - for future use patched_bin.extend(meta); diff --git a/src/executor.rs b/src/executor.rs index dac4e0c..59f151f 100644 --- a/src/executor.rs +++ b/src/executor.rs @@ -64,11 +64,11 @@ pub async fn run_standalone(bin: Vec) -> Result { } if idx == 3 { - bytecode_offset = u64::from_ne_bytes(chunk.try_into().unwrap()); + bytecode_offset = u64::from_le_bytes(chunk.try_into().unwrap()); } if idx == 2 { - bytecode_size = u64::from_ne_bytes(chunk.try_into().unwrap()); + bytecode_size = u64::from_le_bytes(chunk.try_into().unwrap()); } ControlFlow::Continue(())