Skip to content

Commit

Permalink
Fix rangedetails path (#123)
Browse files Browse the repository at this point in the history
* rangedetails: don't return dangling pointers

* size is a usize

* Actually build the RangeDetails at the right time

* Use lifetime parameter

* make sure path lives long enough

* fmt
  • Loading branch information
s1341 authored Jan 8, 2024
1 parent 92cde4e commit 6383f77
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions frida-gum/src/range_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
allow(clippy::unnecessary_cast)
)]

extern crate alloc;
use {
crate::MemoryRange,
alloc::string::String,
core::{
ffi::{c_void, CStr},
marker::PhantomData,
Expand Down Expand Up @@ -42,7 +44,7 @@ pub enum PageProtection {
/// The file association to a page.
#[derive(Clone)]
pub struct FileMapping<'a> {
path: &'a str,
path: String,
size: usize,
offset: u64,
phantom: PhantomData<&'a gum_sys::GumFileMapping>,
Expand All @@ -55,7 +57,7 @@ impl<'a> FileMapping<'a> {
} else {
Some(unsafe {
Self {
path: CStr::from_ptr((*file).path).to_str().unwrap(),
path: CStr::from_ptr((*file).path).to_string_lossy().into_owned(),
size: (*file).size as usize,
offset: (*file).offset,
phantom: PhantomData,
Expand All @@ -66,7 +68,7 @@ impl<'a> FileMapping<'a> {

/// The path of the file mapping on disk.
pub fn path(&self) -> &str {
self.path
&self.path
}

/// The offset into the file mapping.
Expand Down

0 comments on commit 6383f77

Please sign in to comment.