readlink: symlink loop handling (#3717)

readlink: fix symlink loop handling
This commit is contained in:
Niyaz Nigmatullin
2022-07-14 22:32:55 +02:00
committed by GitHub
parent 882cd527ff
commit 0ea3a735ca
2 changed files with 12 additions and 1 deletions
+2 -1
View File
@@ -84,7 +84,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
if verbose {
return Err(USimpleError::new(
1,
format!("{}: errno {}", f.maybe_quote(), err.raw_os_error().unwrap()),
err.map_err_context(move || f.maybe_quote().to_string())
.to_string(),
));
} else {
return Err(1.into());
+10
View File
@@ -70,3 +70,13 @@ fn test_long_redirection_to_root() {
println!("expect: {:?}", expect);
assert_eq!(actual, expect);
}
#[test]
fn test_symlink_to_itself_verbose() {
let (at, mut ucmd) = at_and_ucmd!();
at.relative_symlink_file("a", "a");
ucmd.args(&["-ev", "a"])
.fails()
.code_is(1)
.stderr_contains("Too many levels of symbolic links");
}