Skip to content

Commit 4054779

Browse files
committed
Fix symlink traversal
1 parent ccac2b3 commit 4054779

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/lib.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,15 @@ impl PathWrapper {
337337
let is_directory = e
338338
.file_type()
339339
.ok()
340-
.map(|file_type| file_type.is_dir())
340+
.and_then(|file_type| {
341+
// We need to use fs::metadata to resolve the actual path
342+
// if it's a symlink.
343+
if file_type.is_symlink() {
344+
None
345+
} else {
346+
Some(file_type.is_dir())
347+
}
348+
})
341349
.or_else(|| fs::metadata(&path).map(|m| m.is_dir()).ok())
342350
.unwrap_or(false);
343351
Self { path, is_directory }

0 commit comments

Comments
 (0)