All four findutils binaries collect their arguments with std::env::args().collect::<Vec<String>>(). std::env::args() panics when any argument is not valid Unicode (it is documented as such, and internally unwraps the OsString → String conversion). Since Unix paths are arbitrary byte strings — not necessarily UTF-8 — passing a filename that isn't valid UTF-8 aborts the process before any work is done:
| site |
code |
src/find/main.rs:13 |
let args = std::env::args().collect::<Vec<String>>(); |
src/locate/main.rs:6 |
(identical) |
src/xargs/main.rs:8 |
(identical) |
src/updatedb/main.rs:6 |
(identical) |
$ find $'\xff'
thread 'main' panicked at library/std/src/env.rs:879:51:
called `Result::unwrap()` on an `Err` value: "\xFF"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
$ echo $?
101
GNU findutils, same input:
$ /usr/bin/find $'\xff'
/usr/bin/find: ‘\377’: No such file or directory
$ echo $?
1
All four binaries abort identically (<bin> $'\xff' → exit 101): find, locate, xargs, updatedb.
All four findutils binaries collect their arguments with
std::env::args().collect::<Vec<String>>().std::env::args()panics when any argument is not valid Unicode (it is documented as such, and internally unwraps theOsString → Stringconversion). Since Unix paths are arbitrary byte strings — not necessarily UTF-8 — passing a filename that isn't valid UTF-8 aborts the process before any work is done:src/find/main.rs:13let args = std::env::args().collect::<Vec<String>>();src/locate/main.rs:6src/xargs/main.rs:8src/updatedb/main.rs:6GNU findutils, same input:
All four binaries abort identically (
<bin> $'\xff'→ exit 101):find,locate,xargs,updatedb.