Repository navigation
find: reject -files0-from /dev/stdin with -ok/-okdir (fixes #957) - #1054
Open
pethapixels-create wants to merge 4 commits into
Open
pethapixels-create wants to merge 4 commits into
pethapixels-create wants to merge 4 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1054 +/- ##
==========================================
+ Coverage 92.43% 92.45% +0.01%
==========================================
Files 38 38
Lines 8887 8908 +21
Branches 440 444 +4
==========================================
+ Hits 8215 8236 +21
Misses 532 532
Partials 140 140 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merging this PR will not alter performance1 warning
Comparing |
Contributor
|
i don't think we want PR_BODY.md in the tree ;) and sorry but it needs to be rebased, and rustfmt is sad :) |
pethapixels-create
force-pushed
the
fix/issue-957
branch
from
November 26, 2026 04:11
196a2b6 to
3b1e9c9
Compare
Signed-off-by: pethapixels-create <349370243+pethapixels-create@users.noreply.github.com>
Signed-off-by: pethapixels-create <349370243+pethapixels-create@users.noreply.github.com>
…erage) Adds files0_from_missing_file_with_ok_reports_open_error, exercising the metadata-error (false-return) branch of refers_to_stdin: a nonexistent -files0-from name is not standard input, so the interactive-exec guard does not fire and find falls through to the normal 'cannot open' error. Raises patch coverage flagged by codecov (was 73.91%). Signed-off-by: pethapixels-create <349370243+pethapixels-create@users.noreply.github.com>
pethapixels-create
force-pushed
the
fix/issue-957
branch
from
November 26, 2026 08:42
0d8d0be to
3208d88
Compare
Add a focused unit test exercising all three branches of refers_to_stdin (matching /dev/stdin, non-matching regular file, missing-file error) to lift codecov patch coverage on the new -files0-from + -ok/-okdir guard. Simplify refers_to_stdin to a single let-else: /dev/stdin is a symlink to /proc/self/fd/0 and metadata() follows symlinks, so statting it already resolves to fd 0's actual file. This removes the redundant procfs lookup and its environment-impossible fallback branch, making the helper fully coverable while preserving identical behaviour. Signed-off-by: pethapixels-create <349370243+pethapixels-create@users.noreply.github.com>
pethapixels-create
force-pushed
the
fix/issue-957
branch
from
November 26, 2026 09:39
1655752 to
1fc7bd0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #957:
finddid not reject combining-files0-from /dev/stdinwith the interactive-ok/-okdiractions.GNU
findrejects this combination because both-files0-from /dev/stdinand-ok/-okdirconsume standard input, which is ambiguous. uutils previously accepted it silently.Root cause
In
src/find/mod.rs, the-files0-fromvalidation only rejected the literal-(standard input) when combined with-ok/-okdir:This guard never fired for
-files0-from /dev/stdin(or/dev/fd/0,/proc/self/fd/0, or a list file that is also redirected onto stdin), because the source string was not the literal-. So the ambiguous "both actions read stdin" case slipped through.Fix
Added a
refers_to_stdin(name)helper (insrc/find/mod.rs) that compares the file named by-files0-fromagainst the actual open file descriptor 0 by device/inode identity (via/proc/self/fd/Non Unix, with a/dev/stdinfallback; returnsfalseon non-Unix). The existingname == "-"check is extended so that, when-ok/-okdiris present,findalso rejects any source that refers to standard input — including/dev/stdin,/dev/fd/0,/proc/self/fd/0, and a redirected list file — before doing any work:The new error message matches GNU's exact diagnostic (including the
: '<name>'suffix) and exits with status 1. The change is small and idiomatic: it reuses the existingconfig.interactive_execflag and adds one focused helper.Behavior parity with GNU find
Verified against GNU findutils 4.10.0 (
/usr/bin/find,LC_ALL=C):-files0-from /dev/stdin -ok echo {} \;-files0-from /dev/stdin -okdir echo {} \;-files0-from <list> -ok echo {} \; < list(same file on stdin)-files0-from <regular-file> -ok echo {} \;(no stdin redirect)GNU's exact diagnostic (note the
: '<name>'suffix, which the implementation reproduces):Regression tests
Added two tests to
tests/test_find.rs:files0_from_dev_stdin_rejected_with_ok— for both-okand-okdir, and for each of/dev/stdin,/dev/fd/0,/proc/self/fd/0, assertsfind -files0-from <alias> <action> echo {} \;fails with exit code 1, no stdout, and the GNU-matching error message (including the: '<alias>'suffix).files0_from_same_file_as_stdin_rejected_with_ok— passes a regular file as both the-files0-fromsource and stdin (< list) with-ok; asserts it is rejected with exit code 1 and the GNU-matching message.Test evidence
Full suite (clean pass, no failures):