diff --git a/src/DMRaid.cc b/src/DMRaid.cc index da825305..9b51af8a 100644 --- a/src/DMRaid.cc +++ b/src/DMRaid.cc @@ -128,12 +128,14 @@ bool DMRaid::is_dmraid_device( const Glib::ustring & dev_path ) //Path is a symbolic link so find real path char c_str[4096+1] ; //FIXME: it seems realpath is very unsafe to use (manpage)... - realpath( dev_path .c_str(), c_str ) ; - Glib::ustring tmp_path = c_str ; - if ( tmp_path .length() > 0 ) - for ( unsigned int k=0; k < dmraid_devices .size(); k++ ) - if ( tmp_path .find( dmraid_devices[k] ) != Glib::ustring::npos ) - device_found = true ; + if ( realpath( dev_path .c_str(), c_str ) != NULL ) + { + Glib::ustring tmp_path = c_str ; + if ( tmp_path .length() > 0 ) + for ( unsigned int k=0; k < dmraid_devices .size(); k++ ) + if ( tmp_path .find( dmraid_devices[k] ) != Glib::ustring::npos ) + device_found = true ; + } } } @@ -196,12 +198,14 @@ Glib::ustring DMRaid::get_dmraid_name( const Glib::ustring & dev_path ) //Path is a symbolic link so find real path char c_str[4096+1] ; //FIXME: it seems realpath is very unsafe to use (manpage)... - realpath( dev_path .c_str(), c_str ) ; - Glib::ustring tmp_path = c_str ; - if ( tmp_path .length() > 0 ) - for ( unsigned int k=0; k < dmraid_devices .size(); k++ ) - if ( tmp_path .find( dmraid_devices[k] ) != Glib::ustring::npos ) - dmraid_name = dmraid_devices[k] ; + if( realpath( dev_path .c_str(), c_str ) != NULL ) + { + Glib::ustring tmp_path = c_str ; + if ( tmp_path .length() > 0 ) + for ( unsigned int k=0; k < dmraid_devices .size(); k++ ) + if ( tmp_path .find( dmraid_devices[k] ) != Glib::ustring::npos ) + dmraid_name = dmraid_devices[k] ; + } } }