]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
lib: call Curl_strntolower instead of doing crafted loops
authorDaniel Stenberg <daniel@haxx.se>
Mon, 13 May 2024 21:11:46 +0000 (23:11 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 14 May 2024 06:00:19 +0000 (08:00 +0200)
Closes #13627

lib/hostip.c
lib/urlapi.c

index 2bd5dbfa0257e5fe40b56b9d5d6ec6e540c474be..4b7ac2577f2ae34220cc02e55d33fa24fda5a098 100644 (file)
@@ -167,17 +167,12 @@ create_hostcache_id(const char *name,
                     int port, char *ptr, size_t buflen)
 {
   size_t len = nlen ? nlen : strlen(name);
-  size_t olen = 0;
   DEBUGASSERT(buflen >= MAX_HOSTCACHE_LEN);
   if(len > (buflen - 7))
     len = buflen - 7;
   /* store and lower case the name */
-  while(len--) {
-    *ptr++ = Curl_raw_tolower(*name++);
-    olen++;
-  }
-  olen += msnprintf(ptr, 7, ":%u", port);
-  return olen;
+  Curl_strntolower(ptr, name, len);
+  return msnprintf(&ptr[len], 7, ":%u", port) + len;
 }
 
 struct hostcache_prune_data {
index 8e8625d6f22e854b03cfa8c4445d23e6314ca88c..eb039668767c866c445af7a43ee7432261a24848 100644 (file)
@@ -234,10 +234,8 @@ size_t Curl_is_absolute_url(const char *url, char *buf, size_t buflen,
     /* the length of the scheme is the name part only */
     size_t len = i;
     if(buf) {
+      Curl_strntolower(buf, url, i);
       buf[i] = 0;
-      while(i--) {
-        buf[i] = Curl_raw_tolower(url[i]);
-      }
     }
     return len;
   }