Skip to content

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

Merged
RenjiSann merged 1 commit into
uutils:mainfrom
koopatroopa787:fix-hashsum-status-no-output
Jul 31, 2026
Merged

RenjiSann merged 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.

@github-actions

github-actions Bot commented Jun 19, 2026 •

Copy link
Copy Markdown

GNU testsuite comparison:

Skipping an intermittent issue tests/date/date-locale-hour (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tail/symlink (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/printf/printf-surprise is now being skipped but was previously passing.
Congrats! The gnu test tests/rm/many-dir-entries-vs-OOM is now passing!

…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.
@koopatroopa787
koopatroopa787 force-pushed the fix-hashsum-status-no-output branch from b2a5285 to 7486817 Compare June 25, 2026 16:00
@RenjiSann
RenjiSann merged commit e0fef2a into uutils:main Jul 31, 2026
129 of 173 checks passed
@RenjiSann

Copy link
Copy Markdown
Collaborator

Thank you !

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

2 participants