Skip to content

Commit 9deec1a

Browse files
committed
MachO: display complete @rpath
1 parent aab7d16 commit 9deec1a

File tree

2 files changed

+12
-19
lines changed

2 files changed

+12
-19
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ See [examples/](https://github.com/etke/checksec.rs/tree/master/examples) for li
141141
* Rpath RW
142142
* Platform independent checks
143143
* MachO
144-
* `@rpath` contents into `shared::VecRpath` similar to `DT_RPATH`/`DT_RUNPATH` on ELFs
145144
* Code signature validation
146145

147146
### checksec todos

src/macho.rs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::fmt;
88

99
#[cfg(feature = "color")]
1010
use crate::colorize_bool;
11-
//use crate::shared::{Rpath, VecRpath};
11+
use crate::shared::{Rpath, VecRpath};
1212

1313
const MH_ALLOW_STACK_EXECUTION: u32 = 0x0002_0000;
1414
const MH_PIE: u32 = 0x0020_0000;
@@ -55,8 +55,7 @@ pub struct CheckSecResults {
5555
/// Restrict segment
5656
pub restrict: bool,
5757
/// Load Command @rpath
58-
//rpath: VecRpath,
59-
pub rpath: bool,
58+
pub rpath: VecRpath,
6059
}
6160
impl CheckSecResults {
6261
#[must_use]
@@ -127,8 +126,7 @@ impl fmt::Display for CheckSecResults {
127126
"Restrict:".bold(),
128127
colorize_bool!(self.restrict),
129128
"RPath:".bold(),
130-
//self.rpath
131-
colorize_bool!(self.rpath)
129+
self.rpath
132130
)
133131
}
134132
}
@@ -173,9 +171,8 @@ pub trait Properties {
173171
fn has_pie(&self) -> bool;
174172
/// check for `___restrict` segment name
175173
fn has_restrict(&self) -> bool;
176-
//fn has_rpath(&self) -> VecRpath;
177174
/// check for `RPath` in load commands
178-
fn has_rpath(&self) -> bool;
175+
fn has_rpath(&self) -> VecRpath;
179176
}
180177
impl Properties for MachO<'_> {
181178
fn has_arc(&self) -> bool {
@@ -264,18 +261,15 @@ impl Properties for MachO<'_> {
264261
}
265262
false
266263
}
267-
//fn has_rpath(&self) -> VecRpath {
268-
fn has_rpath(&self) -> bool {
269-
// simply check for existence of @rpath command for now
270-
// parse out rpath entries similar to elf later
271-
// paths separated by `;` instead of `:` like the elf counterpart
272-
for loadcmd in &self.load_commands {
273-
if let CommandVariant::Rpath(_) = loadcmd.command {
274-
return true;
275-
//return VecRpath::new(vec![Rpath::Yes("true".to_string())]);
264+
fn has_rpath(&self) -> VecRpath {
265+
if self.rpaths.is_empty() {
266+
return VecRpath::new(vec![Rpath::None]);
267+
} else {
268+
let mut rpath_vec = Vec::with_capacity(self.rpaths.len());
269+
for i in &self.rpaths {
270+
rpath_vec.push(Rpath::Yes(i.to_string()));
276271
}
272+
return VecRpath::new(rpath_vec);
277273
}
278-
//VecRpath::new(vec![Rpath::None])
279-
false
280274
}
281275
}

0 commit comments

Comments
 (0)