Skip to content

cp: harden sparse_copy against 32-bit panic and EOF hang#12649

Open
sylvestre wants to merge 1 commit into
uutils:mainfrom
sylvestre:cp-sparse-copy-hardening
Open

cp: harden sparse_copy against 32-bit panic and EOF hang#12649
sylvestre wants to merge 1 commit into
uutils:mainfrom
sylvestre:cp-sparse-copy-hardening

Conversation

@sylvestre
Copy link
Copy Markdown
Contributor

Use u64 for the file size and offset instead of narrowing to usize with try_into().unwrap(), which panicked on 32-bit when the source exceeded usize::MAX. Also break the copy loop on a zero-byte read so a source that shrinks mid-copy no longer spins forever.

closes: #12648
and #12647

Use u64 for the file size and offset instead of narrowing to usize with
try_into().unwrap(), which panicked on 32-bit when the source exceeded
usize::MAX. Also break the copy loop on a zero-byte read so a source that
shrinks mid-copy no longer spins forever.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

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/tail-n0f (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/rm/many-dir-entries-vs-OOM is now being skipped but was previously passing.
Congrats! The gnu test tests/printf/printf-surprise 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.

cp: --sparse=always hangs if the source is truncated mid-copy

2 participants