@@ -8,7 +8,7 @@ use std::fmt;
8
8
9
9
#[ cfg( feature = "color" ) ]
10
10
use crate :: colorize_bool;
11
- // use crate::shared::{Rpath, VecRpath};
11
+ use crate :: shared:: { Rpath , VecRpath } ;
12
12
13
13
const MH_ALLOW_STACK_EXECUTION : u32 = 0x0002_0000 ;
14
14
const MH_PIE : u32 = 0x0020_0000 ;
@@ -55,8 +55,7 @@ pub struct CheckSecResults {
55
55
/// Restrict segment
56
56
pub restrict : bool ,
57
57
/// Load Command @rpath
58
- //rpath: VecRpath,
59
- pub rpath : bool ,
58
+ pub rpath : VecRpath ,
60
59
}
61
60
impl CheckSecResults {
62
61
#[ must_use]
@@ -127,8 +126,7 @@ impl fmt::Display for CheckSecResults {
127
126
"Restrict:" . bold( ) ,
128
127
colorize_bool!( self . restrict) ,
129
128
"RPath:" . bold( ) ,
130
- //self.rpath
131
- colorize_bool!( self . rpath)
129
+ self . rpath
132
130
)
133
131
}
134
132
}
@@ -173,9 +171,8 @@ pub trait Properties {
173
171
fn has_pie ( & self ) -> bool ;
174
172
/// check for `___restrict` segment name
175
173
fn has_restrict ( & self ) -> bool ;
176
- //fn has_rpath(&self) -> VecRpath;
177
174
/// check for `RPath` in load commands
178
- fn has_rpath ( & self ) -> bool ;
175
+ fn has_rpath ( & self ) -> VecRpath ;
179
176
}
180
177
impl Properties for MachO < ' _ > {
181
178
fn has_arc ( & self ) -> bool {
@@ -264,18 +261,15 @@ impl Properties for MachO<'_> {
264
261
}
265
262
false
266
263
}
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 ( ) ) ) ;
276
271
}
272
+ return VecRpath :: new ( rpath_vec) ;
277
273
}
278
- //VecRpath::new(vec![Rpath::None])
279
- false
280
274
}
281
275
}
0 commit comments