setopt: fix checking range for CURLOPT_MAXCONNECTS#20414
Closed
MAntoniak wants to merge 1 commit intocurl:masterfrom
Closed
setopt: fix checking range for CURLOPT_MAXCONNECTS#20414MAntoniak wants to merge 1 commit intocurl:masterfrom
MAntoniak wants to merge 1 commit intocurl:masterfrom
Conversation
Member
|
I assume you are speaking about platforms where int and long are the same size, like Windows? LONG_MAX may be greater than the maximum size of the uint32_t we assign to, how about the way we do it elsewhere: diff --git a/lib/setopt.c b/lib/setopt.c
index 2fc90c2..5034c4a 100644
--- a/lib/setopt.c
+++ b/lib/setopt.c
@@ -851,9 +851,9 @@ static CURLcode setopt_long_net(struct Curl_easy *data, CURLoption option,
s->dns_cache_timeout_ms = -1;
break;
case CURLOPT_MAXCONNECTS:
- result = value_range(&arg, 1, 1, UINT_MAX);
+ result = value_range(&arg, 1, 1, INT_MAX);
if(!result)
- s->maxconnects = (unsigned int)arg;
+ s->maxconnects = (uint32_t)arg;
break;
case CURLOPT_SERVER_RESPONSE_TIMEOUT:
return setopt_set_timeout_sec(&s->server_response_timeout, arg); |
Contributor
Author
Yes, I forgot to mention that.
LGTM! I'll push your version. |
…imit as INT_MAX instead of UINT_MAX.
de87f17 to
f8df169
Compare
|
Analysis of PR #20414 at f8df1697: Test 3027 failed, which has NOT been flaky recently, so there could be a real issue in this PR. Note that this test has failed in 2 different CI jobs (the link just goes to one of them). Generated by Testclutch |
Member
|
Thanks |
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.
UINT_MAX can be converted to -1L. In this case, the value_range function will return an incorrect value of 0xFFFFFFFF, because 1 is greater than -1.
Using the upper limit as INT_MAX instead of UINT_MAX.