lib: call Curl_strntolower instead of doing crafted loops

Closes #13627
This commit is contained in:
Daniel Stenberg 2024-05-13 23:11:46 +02:00
parent 9d6d614264
commit aef369867f
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
2 changed files with 3 additions and 10 deletions

View File

@ -167,17 +167,12 @@ create_hostcache_id(const char *name,
int port, char *ptr, size_t buflen) int port, char *ptr, size_t buflen)
{ {
size_t len = nlen ? nlen : strlen(name); size_t len = nlen ? nlen : strlen(name);
size_t olen = 0;
DEBUGASSERT(buflen >= MAX_HOSTCACHE_LEN); DEBUGASSERT(buflen >= MAX_HOSTCACHE_LEN);
if(len > (buflen - 7)) if(len > (buflen - 7))
len = buflen - 7; len = buflen - 7;
/* store and lower case the name */ /* store and lower case the name */
while(len--) { Curl_strntolower(ptr, name, len);
*ptr++ = Curl_raw_tolower(*name++); return msnprintf(&ptr[len], 7, ":%u", port) + len;
olen++;
}
olen += msnprintf(ptr, 7, ":%u", port);
return olen;
} }
struct hostcache_prune_data { struct hostcache_prune_data {

View 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 */ /* the length of the scheme is the name part only */
size_t len = i; size_t len = i;
if(buf) { if(buf) {
Curl_strntolower(buf, url, i);
buf[i] = 0; buf[i] = 0;
while(i--) {
buf[i] = Curl_raw_tolower(url[i]);
}
} }
return len; return len;
} }