Skip to content

more: avoid overflow when -n is the maximum u16 value#12970

Open
SAY-5 wants to merge 1 commit into
uutils:mainfrom
SAY-5:more-lines-overflow
Open

more: avoid overflow when -n is the maximum u16 value#12970
SAY-5 wants to merge 1 commit into
uutils:mainfrom
SAY-5:more-lines-overflow

Conversation

@SAY-5

@SAY-5 SAY-5 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

more -n 65535 panics with "attempt to add with overflow". The -n/--lines value is parsed as a u16, and the banner adjustment adds 1, which overflows when the value is u16::MAX.

Use saturating_add so the maximum value is accepted instead of panicking. Added a unit test covering the u16::MAX case.

Fixes #12784.

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
@oech3

oech3 commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Is this compatible with GNU util-linux's more?

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(more): when -n is a max number of u16 date type, more panics

2 participants