diff --git a/src/backup/data_blob.rs b/src/backup/data_blob.rs index 481ff88c..e0378b6c 100644 --- a/src/backup/data_blob.rs +++ b/src/backup/data_blob.rs @@ -1,8 +1,7 @@ use failure::*; use std::convert::TryInto; -use proxmox::tools::io::ops::ReadExtOps; -use crate::tools::write::WriteUtilOps; +use proxmox::tools::io::{ReadExt, WriteExt}; use super::*; @@ -96,7 +95,9 @@ impl DataBlob { iv: [0u8; 16], tag: [0u8; 16], }; - raw_data.write_value(&dummy_head)?; + unsafe { + raw_data.write_le_value(dummy_head)?; + } let (iv, tag) = config.encrypt_to(data, &mut raw_data)?; @@ -104,7 +105,9 @@ impl DataBlob { head: DataBlobHeader { magic, crc: [0; 4] }, iv, tag, }; - (&mut raw_data[0..header_len]).write_value(&head)?; + unsafe { + (&mut raw_data[0..header_len]).write_le_value(head)?; + } return Ok(DataBlob { raw_data }); } else { @@ -117,7 +120,9 @@ impl DataBlob { magic: COMPRESSED_BLOB_MAGIC_1_0, crc: [0; 4], }; - comp_data.write_value(&head)?; + unsafe { + comp_data.write_le_value(head)?; + } zstd::stream::copy_encode(data, &mut comp_data, 1)?; @@ -132,7 +137,9 @@ impl DataBlob { magic: UNCOMPRESSED_BLOB_MAGIC_1_0, crc: [0; 4], }; - raw_data.write_value(&head)?; + unsafe { + raw_data.write_le_value(head)?; + } raw_data.extend_from_slice(data); return Ok(DataBlob { raw_data }); diff --git a/src/backup/data_chunk.rs b/src/backup/data_chunk.rs index 261e3a01..773f7e73 100644 --- a/src/backup/data_chunk.rs +++ b/src/backup/data_chunk.rs @@ -1,7 +1,6 @@ use failure::*; use std::convert::TryInto; -use proxmox::tools::io::ops::ReadExtOps; -use crate::tools::write::WriteUtilOps; +use proxmox::tools::io::{ReadExt, WriteExt}; use super::*; @@ -100,7 +99,9 @@ impl DataChunk { iv: [0u8; 16], tag: [0u8; 16], }; - raw_data.write_value(&dummy_head)?; + unsafe { + raw_data.write_le_value(dummy_head)?; + } let (iv, tag) = config.encrypt_to(data, &mut raw_data)?; @@ -108,7 +109,9 @@ impl DataChunk { head: DataChunkHeader { magic, crc: [0; 4] }, iv, tag, }; - (&mut raw_data[0..header_len]).write_value(&head)?; + unsafe { + (&mut raw_data[0..header_len]).write_le_value(head)?; + } return Ok(DataChunk { digest, raw_data }); } else { @@ -121,7 +124,9 @@ impl DataChunk { magic: COMPRESSED_CHUNK_MAGIC_1_0, crc: [0; 4], }; - comp_data.write_value(&head)?; + unsafe { + comp_data.write_le_value(head)?; + } zstd::stream::copy_encode(data, &mut comp_data, 1)?; @@ -137,7 +142,9 @@ impl DataChunk { magic: UNCOMPRESSED_CHUNK_MAGIC_1_0, crc: [0; 4], }; - raw_data.write_value(&head)?; + unsafe { + raw_data.write_le_value(head)?; + } raw_data.extend_from_slice(data); let chunk = DataChunk { digest, raw_data };