checksum: handle stdin before directory checks#13394
Conversation
|
@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 |
|
GNU testsuite comparison: |
| let ts = TestScenario::new(util_name!()); | ||
| // A directory named "-" must not shadow stdin. | ||
| ts.fixtures.mkdir("-"); | ||
| assert_eq!( |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
Strange that it's not fixed on my side 🤔 $ ./target/debug/sha256sum
sha256sum: -: Is a directory |
Merging this PR will degrade performance by 6.51%
|
| 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)
Footnotes
-
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. ↩
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 existingsha256sumstdin test with a-directory regression fixture.