]> git.proxmox.com Git - proxmox-backup.git/commitdiff
clippy: fix access to unaligned buffer
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 11 Sep 2019 12:45:43 +0000 (14:45 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 11 Sep 2019 12:45:44 +0000 (14:45 +0200)
via the newly introduced ReadExt::read_host_value_boxed()
from proxmox::tools::io.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/backup/fixed_index.rs

index 779dd0b84e20957e3795e93676529c4a8557aebd..8a6801229ee85850a88387a16f586a80b7b1a62f 100644 (file)
@@ -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::<FixedIndexHeader>();
-
-        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<FixedIndexHeader> = unsafe { file.read_host_value_boxed()? };
 
         if header.magic != super::FIXED_SIZED_CHUNK_INDEX_1_0 {
             bail!("got unknown magic number");