From 4dc79bb1d95bac9383c2417eaf2a59e4045560c5 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 11 Sep 2019 14:45:43 +0200 Subject: [PATCH] clippy: fix access to unaligned buffer via the newly introduced ReadExt::read_host_value_boxed() from proxmox::tools::io. Signed-off-by: Wolfgang Bumiller --- src/backup/fixed_index.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/backup/fixed_index.rs b/src/backup/fixed_index.rs index 779dd0b8..8a680122 100644 --- a/src/backup/fixed_index.rs +++ b/src/backup/fixed_index.rs @@ -18,6 +18,8 @@ use chrono::{Local, TimeZone}; use super::ChunkInfo; use super::read_chunk::*; +use proxmox::tools::io::ReadExt; + /// Header format definition for fixed index files (`.fidx`) #[repr(C)] pub struct FixedIndexHeader { @@ -77,11 +79,7 @@ impl FixedIndexReader { file.seek(SeekFrom::Start(0))?; let header_size = std::mem::size_of::(); - - let mut buffer = vec![0u8; header_size]; - file.read_exact(&mut buffer)?; - - let header = unsafe { &mut * (buffer.as_ptr() as *mut FixedIndexHeader) }; + let header: Box = unsafe { file.read_host_value_boxed()? }; if header.magic != super::FIXED_SIZED_CHUNK_INDEX_1_0 { bail!("got unknown magic number");