Skip to content

options: reject trailing text and overflow in --stop-after - #1206

Open
sagaragas wants to merge 1 commit into
RsyncProject:masterfrom
sagaragas:fix-stop-time-overflow
Open

sagaragas wants to merge 1 commit into
RsyncProject:masterfrom
sagaragas:fix-stop-time-overflow

Conversation

@sagaragas

Copy link
Copy Markdown

--stop-after=2h silently runs for 2 minutes and --stop-after=1.5 runs for 1, while --timeout=2h fails with an error.

Large values also overflow long before the bounds check (307445734561825861 wraps to 44s on 64-bit long).

I fixed both in --stop-after and added cases to stop-time.py.

--stop-after parsed its argument with atol(arg) * 60, so values with
units or decimals like --stop-after=2h or --stop-after=1.5 silently ran
for 2 or 1 minutes instead of failing (unlike --timeout=2h). Multiplying
by 60 before bounds checks also hit signed integer overflow on large
values and let wrapped values like 307445734561825861 pass as a small
positive offset on 64-bit long.

Parse the argument with strtol(), reject empty values and trailing
characters, and check val > LONG_MAX / 60 before multiplying by 60.
Add regression cases to testsuite/tests/transfer/stop-time.py.
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.

1 participant