]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
noproxy: simplify, don't mix const non-const in strchr()
authorDaniel Stenberg <daniel@haxx.se>
Sun, 25 Jan 2026 09:46:24 +0000 (10:46 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 25 Jan 2026 10:02:24 +0000 (11:02 +0100)
Ref: #20420
Closes #20425

lib/noproxy.c

index 541765b6502e1be9f1986f99d9a5a9c6af534995..1421fb114de2950ba9306090a7145e6f663318d9 100644 (file)
@@ -148,7 +148,6 @@ static bool match_host(const char *token, size_t tokenlen,
 static bool match_ip(int type, const char *token, size_t tokenlen,
                      const char *name)
 {
-  const char *check = token;
   char *slash;
   unsigned int bits = 0;
   char checkip[128];
@@ -156,11 +155,10 @@ static bool match_ip(int type, const char *token, size_t tokenlen,
     /* this cannot match */
     return FALSE;
   /* copy the check name to a temp buffer */
-  memcpy(checkip, check, tokenlen);
+  memcpy(checkip, token, tokenlen);
   checkip[tokenlen] = 0;
-  check = checkip;
 
-  slash = strchr(check, '/');
+  slash = strchr(checkip, '/');
   /* if the slash is part of this token, use it */
   if(slash) {
     curl_off_t value;
@@ -172,9 +170,9 @@ static bool match_ip(int type, const char *token, size_t tokenlen,
     *slash = 0; /* null-terminate there */
   }
   if(type == TYPE_IPV6)
-    return Curl_cidr6_match(name, check, bits);
+    return Curl_cidr6_match(name, checkip, bits);
   else
-    return Curl_cidr4_match(name, check, bits);
+    return Curl_cidr4_match(name, checkip, bits);
 }
 
 /****************************************************************