Summary
cp --parents -r SRC DEST, where the source path's final component is .., makes uutils cp call root.file_name() — which returns None for such a path — and then .unwrap() it. The unwrap panics and the process aborts with exit code 134. GNU cp reports a normal error (cannot create directory … File exists) and exits 1.
Steps to reproduce
$ mkdir -p /tmp/cpp/src/sub && echo x > /tmp/cpp/src/sub/f && mkdir -p /tmp/cpp/d && cd /tmp/cpp
$ cp --parents -r 'src/sub/..' d
thread 'main' panicked at src/uu/cp/src/copydir.rs:575:49:
called `Option::unwrap()` on a `None` value
$ echo $?
134
Expected behavior
Match GNU: report the error and exit non-zero without crashing.
$ /usr/bin/cp --parents -r 'src/sub/..' d
/usr/bin/cp: cannot create directory 'd/src/sub/..': File exists
$ echo $?
1
Actual behavior
uutils cp panics (Option::unwrap() on a None) and the process aborts with exit code 134, printing a Rust panic message instead of a diagnostic.
Found by our static analysis tooling.
Summary
cp --parents -r SRC DEST, where the source path's final component is.., makes uutilscpcallroot.file_name()— which returnsNonefor such a path — and then.unwrap()it. Theunwrappanics and the process aborts with exit code 134. GNUcpreports a normal error (cannot create directory … File exists) and exits 1.Steps to reproduce
Expected behavior
Match GNU: report the error and exit non-zero without crashing.
Actual behavior
uutils
cppanics (Option::unwrap()on aNone) and the process aborts with exit code 134, printing a Rust panic message instead of a diagnostic.Found by our static analysis tooling.