From d21e99a3f39dc4d15e56b03ae655720c3e9c02dd Mon Sep 17 00:00:00 2001 From: bunnie Date: Sat, 4 Oct 2025 18:52:50 +0800 Subject: [PATCH] implement swap header length reference --- tools/src/swap_writer.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/src/swap_writer.rs b/tools/src/swap_writer.rs index 4a9451e33..da6142030 100644 --- a/tools/src/swap_writer.rs +++ b/tools/src/swap_writer.rs @@ -56,10 +56,9 @@ impl SwapHeader { } /// Returns exactly a page of data with the header format serialized - /// Header format is in loader/src/swap.rs/SwapSourceHeader - pub fn serialize(&self) -> Result<[u8; 4096]> { + pub fn serialize(&self) -> Result<[u8; bao1x_api::offsets::baosec::SWAP_HEADER_LEN]> { let mut data = Cursor::new(Vec::::new()); - let mut output = [0u8; 4096]; + let mut output = [0u8; bao1x_api::offsets::baosec::SWAP_HEADER_LEN]; let mut ssh = SwapSourceHeader::default(); ssh.version = SWAP_VERSION; @@ -140,7 +139,10 @@ impl SwapWriter { ) .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Can't sign swap image"))?; // write the header, less space for the signature - f.write(&unsigned_header[..4096 - bao1x_api::signatures::SIGBLOCK_LEN])?; + f.write( + &unsigned_header + [..bao1x_api::offsets::baosec::SWAP_HEADER_LEN - bao1x_api::signatures::SIGBLOCK_LEN], + )?; f.write(&signed) }