mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
prevent infinite loops while performing stat on symbolic links pointing to themselves
This commit is contained in:
@@ -151,12 +151,19 @@ impl ScpFileTransfer {
|
|||||||
if let Some(symlink_path) = symlink_path.as_ref() {
|
if let Some(symlink_path) = symlink_path.as_ref() {
|
||||||
is_dir = symlink_path.is_dir();
|
is_dir = symlink_path.is_dir();
|
||||||
}
|
}
|
||||||
// Get symlink
|
// Get symlink; PATH mustn't be equal to filename
|
||||||
let symlink: Option<Box<FsEntry>> = match symlink_path {
|
let symlink: Option<Box<FsEntry>> = match symlink_path {
|
||||||
None => None,
|
None => None,
|
||||||
Some(p) => match self.stat(p.as_path()) {
|
Some(p) => match p.file_name().unwrap_or(&std::ffi::OsStr::new(""))
|
||||||
Ok(e) => Some(Box::new(e)),
|
== file_name.as_str()
|
||||||
Err(_) => None, // Ignore errors
|
{
|
||||||
|
// If name is equal, don't stat path; otherwise it would get stuck
|
||||||
|
true => None,
|
||||||
|
false => match self.stat(p.as_path()) {
|
||||||
|
// If path match filename
|
||||||
|
Ok(e) => Some(Box::new(e)),
|
||||||
|
Err(_) => None, // Ignore errors
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
// Check if file_name is '.' or '..'
|
// Check if file_name is '.' or '..'
|
||||||
|
|||||||
Reference in New Issue
Block a user