Skip to content

split: reject a zero chunk count for -n l/N and r/N#12613

Open
leeewee wants to merge 1 commit into
uutils:mainfrom
leeewee:split-reject-zero-chunks
Open

split: reject a zero chunk count for -n l/N and r/N#12613
leeewee wants to merge 1 commit into
uutils:mainfrom
leeewee:split-reject-zero-chunks

Conversation

@leeewee
Copy link
Copy Markdown
Contributor

@leeewee leeewee commented Jun 5, 2026

Fixes #12612

split -n l/0 and split -n r/0 aborted with a divide-by-zero panic: NumberType::from rejected a zero count for the bare N/K/N forms but not for l/N and r/N, so num_chunks == 0 reached the chunk arithmetic.

Reject num_chunks == 0 in those two branches too, returning NumberTypeError::NumberOfChunks like the bare-N form — now matching GNU (split: invalid number of chunks: '0', exit 1). Adds unit + integration regression tests.

`split -n l/0` and `split -n r/0` aborted with a divide-by-zero panic
(`num_bytes / num_chunks` in `n_chunks_by_line` and `i % num_chunks` in
`n_chunks_by_line_round_robin`). `NumberType::from` validated `N > 0` for
the bare `N` / `K/N` forms but not for the `l/N` and `r/N` forms, so a
zero count reached the chunk arithmetic.

Reject `num_chunks == 0` in those two branches, returning
`NumberTypeError::NumberOfChunks` like the bare-`N` form, which matches
GNU (`split: invalid number of chunks: '0'`, exit 1) and validates up
front rather than crashing while reading input.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

GNU testsuite comparison:

Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes 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/pr/bounded-memory is now being skipped but was previously passing.
Congrats! The gnu test tests/unexpand/bounded-memory 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.

split panics (divide-by-zero) on a zero chunk count in -n l/0 and -n r/0

1 participant