Summary
Running ln -r (--relative) with a destination that has no parent — the root / or the empty string "", taken verbatim via -T — panics. relative_path computes the destination's parent with dst.parent().unwrap(), but Path::parent() is None for a prefix-only/root path, so the .unwrap() aborts (exit 134) before any filesystem operation. GNU instead reports /: cannot overwrite directory and exits 1 (/: cannot overwrite directory for /; failed to create symbolic link '': No such file or directory for "").
Steps to reproduce
$ echo data > /tmp/lnsrc
$ ln -rsfT /tmp/lnsrc /
thread 'main' panicked at src/uu/ln/src/ln.rs:398:26:
called `Option::unwrap()` on a `None` value
$ echo $?
134
Expected behavior
Match GNU: report the error and exit non-zero without crashing.
$ /usr/bin/ln -rsfT /tmp/lnsrc /
/usr/bin/ln: /: cannot overwrite directory
$ echo $?
1
Actual behavior
uutils panics with Option::unwrap() on a None value and aborts with exit code 134. The crash happens while building the relative source path, before any link or overwrite check, so it short-circuits the error GNU would otherwise report.
Found by our static analysis tooling.
Summary
Running
ln -r(--relative) with a destination that has no parent — the root/or the empty string"", taken verbatim via-T— panics.relative_pathcomputes the destination's parent withdst.parent().unwrap(), butPath::parent()isNonefor a prefix-only/root path, so the.unwrap()aborts (exit 134) before any filesystem operation. GNU instead reports/: cannot overwrite directoryand exits 1 (/: cannot overwrite directoryfor/;failed to create symbolic link '': No such file or directoryfor"").Steps to reproduce
Expected behavior
Match GNU: report the error and exit non-zero without crashing.
Actual behavior
uutils panics with
Option::unwrap()on aNonevalue and aborts with exit code 134. The crash happens while building the relative source path, before any link or overwrite check, so it short-circuits the error GNU would otherwise report.Found by our static analysis tooling.