From 48e952abded6c347321a6b5823f11e9df750679d Mon Sep 17 00:00:00 2001 From: Philipp Schuster Date: Fri, 3 May 2024 15:20:09 +0200 Subject: [PATCH] miri: fix memory issue --- src/archive.rs | 10 ++++++++-- src/lib.rs | 4 ---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/archive.rs b/src/archive.rs index ff350b8..496e210 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -189,8 +189,14 @@ impl<'a> ArchiveHeaderIterator<'a> { /// Parse the memory at the given block as [`PosixHeader`]. fn block_as_header(&self, block_index: usize) -> &'a PosixHeader { - let hdr_ptr = &self.archive_data[block_index * BLOCKSIZE]; - unsafe { (hdr_ptr as *const u8).cast::().as_ref() }.unwrap() + unsafe { + self.archive_data + .as_ptr() + .add(block_index * BLOCKSIZE) + .cast::() + .as_ref() + .unwrap() + } } } diff --git a/src/lib.rs b/src/lib.rs index 691fe64..f25fef6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -47,10 +47,6 @@ SOFTWARE. //! ```rust //! use tar_no_std::TarArchiveRef; //! -//! // log: not mandatory -//! std::env::set_var("RUST_LOG", "trace"); -//! env_logger::init(); -//! //! // also works in no_std environment (except the println!, of course) //! let archive = include_bytes!("../tests/gnu_tar_default.tar"); //! let archive = TarArchiveRef::new(archive).unwrap();