Skip to content

fix(hashsum): always report malformed input with --status (fixes #12867)#12973

Open
koopatroopa787 wants to merge 1 commit into
uutils:mainfrom
koopatroopa787:fix-hashsum-status-no-output
Open

fix(hashsum): always report malformed input with --status (fixes #12867)#12973
koopatroopa787 wants to merge 1 commit into
uutils:mainfrom
koopatroopa787:fix-hashsum-status-no-output

Conversation

@koopatroopa787

Copy link
Copy Markdown
Contributor

Summary

Fixes #12867.

When md5sum -c --status (or any hashsum variant) receives input where all checksum lines are improperly formatted, it previously exited with an error code but printed no diagnostic at all. GNU coreutils emits "md5sum: 'stdin': no properly formatted checksum lines found" in this case regardless of --status.

The --status flag is documented to suppress per-file OK/FAILED lines, not structural error messages about the input format itself.

Change

In src/uucore/src/lib/features/checksum/validate.rs, removed the opts.verbose.over_status() guard around log_no_properly_formatted():

// Before
if res.total_properly_formatted() == 0 {
    if opts.verbose.over_status() {
        log_no_properly_formatted(filename_display());
    }
    return Err(FileCheckError::Failed);
}

// After
if res.total_properly_formatted() == 0 {
    log_no_properly_formatted(filename_display());
    return Err(FileCheckError::Failed);
}

This fix applies to all hashsum utilities (md5sum, sha256sum, sha512sum, b2sum, etc.) since they share this code path.

Tests

Added test_check_status_reports_malformed_input in tests/by-util/test_md5sum.rs that asserts the error message appears on stderr even with --status.

Note: PR #12622 made the same fix but only added a b2sum test; this PR adds coverage for md5sum and fixes the root cause in the shared validation code.

…ls#12867)

Previously, when all checksum lines were improperly formatted, the
"no properly formatted checksum lines found" error was silently
suppressed when --status was active. RFC-4634 and GNU coreutils both
emit this diagnostic regardless of --status; only per-file
OK/FAILED lines are suppressed.

Remove the `over_status()` guard around `log_no_properly_formatted`
so the error is always printed. Add a regression test for md5sum.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

GNU test failed: tests/cp/sparse-to-pipe. tests/cp/sparse-to-pipe is passing on 'main'. Maybe you have to rebase?
Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes in the 'main' branch)
Note: The gnu test tests/cut/bounded-memory is now being skipped but was previously passing.
Note: The gnu test tests/tail/tail-n0f is now being skipped but was previously passing.
Congrats! The gnu test tests/tail/pipe-f is now passing!

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.

bug(hashsum): uutils show no error when providing an invalid hash and passing the option -c and --status

1 participant