From: Daniel Stenberg Date: Mon, 13 May 2024 21:11:46 +0000 (+0200) Subject: lib: call Curl_strntolower instead of doing crafted loops X-Git-Tag: curl-8_8_0~65 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aef369867f73d761a8a320d9cd2aae87a413d56a;p=thirdparty%2Fcurl.git lib: call Curl_strntolower instead of doing crafted loops Closes #13627 --- diff --git a/lib/hostip.c b/lib/hostip.c index 2bd5dbfa02..4b7ac2577f 100644 --- a/lib/hostip.c +++ b/lib/hostip.c @@ -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 { diff --git a/lib/urlapi.c b/lib/urlapi.c index 8e8625d6f2..eb03966876 100644 --- a/lib/urlapi.c +++ b/lib/urlapi.c @@ -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; }