Skip to content

checksum: handle stdin before directory checks#13394

Open
wtcpython wants to merge 2 commits into
uutils:mainfrom
wtcpython:sha256sum-dash-stdin
Open

checksum: handle stdin before directory checks#13394
wtcpython wants to merge 2 commits into
uutils:mainfrom
wtcpython:sha256sum-dash-stdin

Conversation

@wtcpython

Copy link
Copy Markdown
Contributor

Fixes #13390.

Checksum computation checked whether each operand was a directory before handling - as standard input. As a result, a literal ./- directory caused implicit or explicit stdin input to fail.

Handle - before filesystem checks so it remains stdin regardless of entries in the working directory. Extend the existing sha256sum stdin test with a - directory regression fixture.

@HackingRepo

Copy link
Copy Markdown
Contributor

@wtcpython that is already fixed, uutils 0.8.0 is old the issue already fixed

relunsec@relunsec:~/software/coreutils/target/debug$ ./printf x | ./sha256sum
2d711642b726b04401627ca9fbac32f5c8530fb1903cc4db02258717921a4881  -
relunsec@relunsec:~/software/coreutils/target/debug$ 

please close that pr

@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/misc/usage_vs_getopt (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/date/date-locale-hour (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/misc/io-errors (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tail/retry (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tail/tail-n0f (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/tail/pipe-f is now being skipped but was previously passing.

Comment on lines 42 to 45
let ts = TestScenario::new(util_name!());
// A directory named "-" must not shadow stdin.
ts.fixtures.mkdir("-");
assert_eq!(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make a separate test for that.
Also, can you replicate the test on other test_*sum.rs files ? (though we should ideally unify theses somehow)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I moved the regression coverage into a separate test and added corresponding tests for b2sum, cksum, md5sum, sha1sum, sha224sum, sha256sum, sha384sum, and sha512sum.

I left sum unchanged because it does not use uu_checksum_common::perform_checksum_computation and is not affected by this issue.

@RenjiSann

Copy link
Copy Markdown
Collaborator

@wtcpython that is already fixed, uutils 0.8.0 is old the issue already fixed

relunsec@relunsec:~/software/coreutils/target/debug$ ./printf x | ./sha256sum
2d711642b726b04401627ca9fbac32f5c8530fb1903cc4db02258717921a4881  -
relunsec@relunsec:~/software/coreutils/target/debug$ 

please close that pr

Strange that it's not fixed on my side 🤔

$ ./target/debug/sha256sum
sha256sum: -: Is a directory

@codspeed-hq

codspeed-hq Bot commented Jul 16, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 6.51%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
❌ 4 regressed benchmarks
✅ 334 untouched benchmarks
⏩ 46 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation true_consecutive_calls 170.3 ns 199.4 ns -14.62%
Simulation false_consecutive_calls 170.3 ns 199.4 ns -14.62%
Simulation unexpand_large_file[10] 282.3 ms 291.9 ms -3.3%
Simulation unexpand_many_lines[100000] 134.7 ms 139.3 ms -3.29%
Simulation sort_long_line[10000] 439.3 µs 419.3 µs +4.77%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing wtcpython:sha256sum-dash-stdin (10405a5) with main (9846eb8)

Open in CodSpeed

Footnotes

  1. 46 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sha256sum implicit stdin opens literal ./- directory before stdin handling

3 participants