Fix CVE-2022-22576

Merge: curl/curl@852aa5ad35
This commit is contained in:
Kawe Mazidjatari 2023-06-13 12:20:54 +02:00
parent 8b24c4f7d8
commit 926a34dbbb
3 changed files with 14 additions and 1 deletions

View File

@ -164,6 +164,16 @@ void Curl_strntoupper(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

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

View File

@ -3640,7 +3640,8 @@ 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->oauth_bearer, check->oauth_bearer)) {
/* one of them was different */
continue;
}