]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
setopt: fix checking range for CURLOPT_MAXCONNECTS
authorMichał Antoniak <m.antoniak@posnet.com.pl>
Fri, 23 Jan 2026 15:51:44 +0000 (16:51 +0100)
committerJay Satiro <raysatiro@yahoo.com>
Fri, 23 Jan 2026 21:30:09 +0000 (16:30 -0500)
- Use upper limit INT_MAX instead of UINT_MAX.

UINT_MAX doesn't work as the max value for the variable since it is
passed as a long and becomes -1 on platforms that have same sized
int and long, like Windows.

Closes https://github.com/curl/curl/pull/20414

lib/setopt.c

index 2fc90c25ec8e54f0561b7cb67b9f5d3d1a26c41a..5034c4a5f0b7336cc733510a920e093971851515 100644 (file)
@@ -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);