tool_urlglob: avoid overflow at end of range#21529
Closed
Conversation
Due to how the range span globbing code works, a range that ends with 9223372036854775807 (the maximum signed 63 bit value) cannot be used as it triggers an integer overflow. Verified in test 2092 Reported-by: Andrew Nesbit
There was a problem hiding this comment.
Pull request overview
This PR prevents an integer overflow in curl tool URL range-globbing when the numeric range ends at 9223372036854775807 (i.e., CURL_OFF_T_MAX on typical 64-bit builds). It adds a regression test to ensure the tool fails safely instead of overflowing.
Changes:
- Add a numeric-range validation guard in
src/tool_urlglob.cto avoidcurl_off_toverflow when advancing the range counter. - Add new regression test
tests/data/test2092covering a range that ends at9223372036854775807. - Register the new test in
tests/data/Makefile.am.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/tool_urlglob.c |
Adds a numeric range constraint to prevent overflow when incrementing the glob counter. |
tests/data/test2092 |
New regression test for a numeric range ending at 9223372036854775807. |
tests/data/Makefile.am |
Includes test2092 in the test suite list. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
better error message Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Due to how the range span globbing code works, a range that ends with 9223372036854775807 (the maximum signed 63 bit value) cannot be used as it triggers an integer overflow.
Verified in test 2092
Reported-by: Andrew Nesbit