1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

readlink: symlink loop handling (#3717)

readlink: fix symlink loop handling
This commit is contained in:
Niyaz Nigmatullin 2022-07-14 23:32:55 +03:00 committed by GitHub
parent 882cd527ff
commit 0ea3a735ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

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());

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");
}