@@ -8,7 +8,7 @@ use std::fmt;
88
99#[ cfg( feature = "color" ) ]
1010use crate :: colorize_bool;
11- // use crate::shared::{Rpath, VecRpath};
11+ use crate :: shared:: { Rpath , VecRpath } ;
1212
1313const MH_ALLOW_STACK_EXECUTION : u32 = 0x0002_0000 ;
1414const 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}
6160impl 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}
180177impl 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