lib: add a Curl_bufref_uptr() function and use it

Function Curl_bufref_ptr() now returns a const char *.
New function Curl_bufref_uptr() returns a const unsigned char *.

Usage and doc updated.

Closes #19827
This commit is contained in:
Patrick Monnerat 2025-12-03 18:36:03 +01:00 committed by Daniel Stenberg
parent 39d1976b7f
commit f39b8a1174
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
13 changed files with 40 additions and 23 deletions

View file

@ -69,7 +69,7 @@ CURLcode Curl_auth_create_cram_md5_message(const struct bufref *chlg,
/* Update the digest with the given challenge */
if(Curl_bufref_len(chlg))
Curl_HMAC_update(ctxt, Curl_bufref_ptr(chlg),
Curl_HMAC_update(ctxt, Curl_bufref_uptr(chlg),
curlx_uztoui(Curl_bufref_len(chlg)));
/* Finalise the digest */

View file

@ -271,7 +271,7 @@ static CURLcode auth_decode_digest_md5_message(const struct bufref *chlgref,
char *alg, size_t alen,
char *qop, size_t qlen)
{
const char *chlg = (const char *)Curl_bufref_ptr(chlgref);
const char *chlg = Curl_bufref_ptr(chlgref);
/* Ensure we have a valid challenge message */
if(!Curl_bufref_len(chlgref))

View file

@ -98,8 +98,7 @@ CURLcode Curl_auth_gsasl_token(struct Curl_easy *data,
char *response;
size_t outlen;
res = gsasl_step(gsasl->client,
(const char *)Curl_bufref_ptr(chlg), Curl_bufref_len(chlg),
res = gsasl_step(gsasl->client, Curl_bufref_ptr(chlg), Curl_bufref_len(chlg),
&response, &outlen);
if(res != GSASL_OK && res != GSASL_NEEDS_MORE) {
failf(data, "GSASL step: %s", gsasl_strerror(res));

View file

@ -255,7 +255,7 @@ static CURLcode ntlm_decode_type2_target(struct Curl_easy *data,
{
unsigned short target_info_len = 0;
unsigned int target_info_offset = 0;
const unsigned char *type2 = Curl_bufref_ptr(type2ref);
const unsigned char *type2 = Curl_bufref_uptr(type2ref);
size_t type2len = Curl_bufref_len(type2ref);
#ifdef CURL_DISABLE_VERBOSE_STRINGS
@ -355,7 +355,7 @@ CURLcode Curl_auth_decode_ntlm_type2_message(struct Curl_easy *data,
*/
CURLcode result = CURLE_OK;
const unsigned char *type2 = Curl_bufref_ptr(type2ref);
const unsigned char *type2 = Curl_bufref_uptr(type2ref);
size_t type2len = Curl_bufref_len(type2ref);
#ifdef CURL_DISABLE_VERBOSE_STRINGS

View file

@ -209,7 +209,7 @@ CURLcode Curl_auth_decode_ntlm_type2_message(struct Curl_easy *data,
}
/* Store the challenge for later use */
ntlm->input_token = Curl_memdup0((const char *)Curl_bufref_ptr(type2),
ntlm->input_token = Curl_memdup0(Curl_bufref_ptr(type2),
Curl_bufref_len(type2));
if(!ntlm->input_token)
return CURLE_OUT_OF_MEMORY;