Skip to content

Fix cksum oom panic#12925

Closed
killuazoldyck680 wants to merge 6 commits into
uutils:mainfrom
killuazoldyck680:fix-cksum-oom-panic
Closed

Fix cksum oom panic#12925
killuazoldyck680 wants to merge 6 commits into
uutils:mainfrom
killuazoldyck680:fix-cksum-oom-panic

Conversation

@killuazoldyck680

Copy link
Copy Markdown

Hey, tried to fix the OOM panic.

Changes Made:

  • Added a validation guardrail inside the maybe_sanitize_length function.
  • If the parsed bit length exceeds u32::MAX, it now cleanly returns a ChecksumError::InvalidLength instead of allowing the application to panic and crash the terminal.

Tested it locally, and it works perfectly on my machine. Ready for review!

Fixes #12869

@oech3

oech3 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

If the parsed bit length exceeds u32::MAX, it now cleanly returns a ChecksumError::InvalidLength

It is what GNU never do. Please don't make artifactal restriction. People having many RAM cannot calc it.
We should catch OOM instead.

@killuazoldyck680

Copy link
Copy Markdown
Author

ok, will try to fix that.

@oech3

oech3 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

For example, the following command should not panic:

$ ulimit -v 5400
$ cksum -a shake128 -l 65536 /dev/null
memory allocation of 32768 bytes failed
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Aborted                    (core dumped) cksum -a shake128 -l 65536 /dev/null

@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Note: The gnu test tests/cp/link-heap is now being skipped but was previously 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(cksum): panics when using an algorithm shake128 and shake256 with an extremly large length

2 participants