weili e2d84e98d5 locate: don't panic on a too-short --database file
`locate -d <file> <pattern>` panicked (slice index underflow, exit 101) when
the database file is exactly one byte: `check_db` consumes that byte with
`read_exact`, then `read_until(b'\0', ...)` hits EOF and appends nothing,
leaving `buf` empty. `&buf[..buf.len() - 1]` then underflows `buf.len() - 1`
to `usize::MAX` and slices out of bounds.

Strip the trailing nul with `strip_suffix(b"\0")` (falling back to the whole
buffer when `read_until` stopped at EOF without one) instead of slicing
`buf.len() - 1`. An empty buffer now yields `None` (unrecognized format), so
the too-short database is skipped like any other invalid one and locate exits
1 instead of crashing. Adds a regression test.
2026-06-09 22:23:23 +02:00
2026-04-08 16:40:31 +02:00
2023-08-19 19:34:30 +02:00
2026-06-08 22:44:43 +02:00
2017-03-08 14:39:37 +00:00
2025-05-05 09:15:45 -07:00
2026-05-05 09:02:14 +02:00

findutils

Crates.io Discord License dependency status codecov

Rust implementation of GNU findutils: xargs, find, locate and updatedb. The goal is to be a full drop-in replacement of the original commands.

Run the GNU testsuite on rust/findutils:

bash util/build-gnu.sh

# To run a specific test:
bash util/build-gnu.sh tests/misc/help-version.sh

Comparing with GNU

Evolution over time - GNU testsuite Evolution over time - BFS testsuite

Build/run with BFS

bfs is a variant of the UNIX find command that operates breadth-first rather than depth-first.

bash util/build-bfs.sh

# To run a specific test:
bash util/build-bfs.sh posix/basic

For more details, see https://github.com/uutils/findutils-tracking/

S
Description
No description provided
Readme MIT 2.7 MiB
Languages
Rust 98.7%
Shell 1%
Python 0.3%