Summary
split -n l/0 and split -n r/0 abort with a divide-by-zero panic (SIGABRT, exit 134) instead of rejecting the zero chunk count. The -n argument parser validates N > 0 for the bare N and K/N forms, but the l/N (lines) and r/N (round-robin) forms skip that check, so num_chunks = 0 reaches the chunk math: num_bytes / num_chunks in n_chunks_by_line and i % num_chunks in n_chunks_by_line_round_robin. GNU split rejects 0 up front with an error and exits 1.
Steps to reproduce
$ printf 'a\nb\nc\nd\n' > f
$ split -n l/0 f
thread 'main' panicked at src/uu/split/src/split.rs:1272:27:
attempt to divide by zero
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Aborted (core dumped)
$ echo $?
134
$ split -n r/0 f
thread 'main' panicked at src/uu/split/src/split.rs:1412:47:
attempt to calculate the remainder with a divisor of zero
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Aborted (core dumped)
$ echo $?
134
Expected behavior
Match GNU: report the invalid chunk count and exit non-zero without crashing. GNU validates the count up front (it fails the same way even with no input, e.g. -n l/0 </dev/null), so the fix should reject 0 during argument parsing, not lazily while reading input.
$ /usr/bin/split -n l/0 f
/usr/bin/split: invalid number of chunks: ‘0’: Numerical result out of range
$ echo $?
1
$ /usr/bin/split -n r/0 f
/usr/bin/split: invalid number of chunks: ‘0’: Numerical result out of range
$ echo $?
1
Actual behavior
uutils aborts with a Rust arithmetic panic (panic=abort release build → exit 134). Both the l/N (split into N chunks by line) and r/N (round-robin) forms are affected. The bare N (split -n 0) and K/N byte forms are not affected — those branches already reject 0.
Found by our static analysis tooling.
Summary
split -n l/0andsplit -n r/0abort with a divide-by-zero panic (SIGABRT, exit 134) instead of rejecting the zero chunk count. The-nargument parser validatesN > 0for the bareNandK/Nforms, but thel/N(lines) andr/N(round-robin) forms skip that check, sonum_chunks = 0reaches the chunk math:num_bytes / num_chunksinn_chunks_by_lineandi % num_chunksinn_chunks_by_line_round_robin. GNU split rejects0up front with an error and exits 1.Steps to reproduce
Expected behavior
Match GNU: report the invalid chunk count and exit non-zero without crashing. GNU validates the count up front (it fails the same way even with no input, e.g.
-n l/0 </dev/null), so the fix should reject0during argument parsing, not lazily while reading input.Actual behavior
uutils aborts with a Rust arithmetic panic (
panic=abortrelease build → exit 134). Both thel/N(split into N chunks by line) andr/N(round-robin) forms are affected. The bareN(split -n 0) andK/Nbyte forms are not affected — those branches already reject0.Found by our static analysis tooling.