Skip to content

Commit ae6ecb1

Browse files
author
aweinstock
committed
ln: Add test for backup suffix containing slashes.
1 parent 74e6a17 commit ae6ecb1

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

‎tests/by-util/test_ln.rs‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,3 +1023,23 @@ fn test_ln_hard_link_dir() {
10231023
.fails()
10241024
.stderr_contains("hard link not allowed for directory");
10251025
}
1026+
1027+
#[test]
1028+
fn test_ln_backup_no_path_traversal() {
1029+
let scene = TestScenario::new(util_name!());
1030+
let at = &scene.fixtures;
1031+
1032+
at.touch("a");
1033+
at.touch("b");
1034+
at.mkdir("b_");
1035+
1036+
scene
1037+
.ucmd()
1038+
.args(&["-S", "_/../c", "-s", "a", "b"])
1039+
.succeeds();
1040+
1041+
assert!(!at.file_exists("c"));
1042+
assert!(at.plus("b").is_symlink());
1043+
assert!(at.file_exists("b~"));
1044+
assert!(!at.plus("b~").is_symlink());
1045+
}

0 commit comments

Comments
 (0)