Repair CVE-2022-22576

This commit is contained in:
liwenjie 2022-11-07 10:30:27 +08:00 committed by handsome_feng
parent e217d423b7
commit 3cb696cabc
3 changed files with 23 additions and 1 deletions

View File

@ -249,6 +249,16 @@ void Curl_strntolower(char *dest, const char *src, size_t n)
} while(*src++ && --n);
}
/* Compare case-sensitive NUL-terminated strings, taking care of possible
* null pointers. Return true if arguments match.
*/
bool Curl_safecmp(char *a, char *b)
{
if(a && b)
return !strcmp(a, b);
return !a && !b;
}
/* --- public functions --- */
int curl_strequal(const char *first, const char *second)

View File

@ -49,4 +49,6 @@ char Curl_raw_tolower(char in);
void Curl_strntoupper(char *dest, const char *src, size_t n);
void Curl_strntolower(char *dest, const char *src, size_t n);
bool Curl_safecmp(char *a, char *b);
#endif /* HEADER_CURL_STRCASE_H */

View File

@ -1219,7 +1219,9 @@ ConnectionExists(struct Curl_easy *data,
/* This protocol requires credentials per connection,
so verify that we're using the same name and password as well */
if(strcmp(needle->user, check->user) ||
strcmp(needle->passwd, check->passwd)) {
strcmp(needle->passwd, check->passwd) ||
!Curl_safecmp(needle->sasl_authzid, check->sasl_authzid) ||
!Curl_safecmp(needle->oauth_bearer, check->oauth_bearer)) {
/* one of them was different */
continue;
}
@ -3355,6 +3357,14 @@ static CURLcode create_conn(struct Curl_easy *data,
}
}
if(data->set.str[STRING_BEARER]) {
conn->oauth_bearer = strdup(data->set.str[STRING_BEARER]);
if(!conn->oauth_bearer) {
result = CURLE_OUT_OF_MEMORY;
goto out;
}
}
#ifdef USE_UNIX_SOCKETS
if(data->set.str[STRING_UNIX_SOCKET_PATH]) {
conn->unix_domain_socket = strdup(data->set.str[STRING_UNIX_SOCKET_PATH]);