mirror of https://gitee.com/openkylin/curl.git
Repair CVE-2022-22576
This commit is contained in:
parent
e217d423b7
commit
3cb696cabc
|
@ -249,6 +249,16 @@ void Curl_strntolower(char *dest, const char *src, size_t n)
|
||||||
} while(*src++ && --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 --- */
|
/* --- public functions --- */
|
||||||
|
|
||||||
int curl_strequal(const char *first, const char *second)
|
int curl_strequal(const char *first, const char *second)
|
||||||
|
|
|
@ -49,4 +49,6 @@ char Curl_raw_tolower(char in);
|
||||||
void Curl_strntoupper(char *dest, const char *src, size_t n);
|
void Curl_strntoupper(char *dest, const char *src, size_t n);
|
||||||
void Curl_strntolower(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 */
|
#endif /* HEADER_CURL_STRCASE_H */
|
||||||
|
|
12
lib/url.c
12
lib/url.c
|
@ -1219,7 +1219,9 @@ ConnectionExists(struct Curl_easy *data,
|
||||||
/* This protocol requires credentials per connection,
|
/* This protocol requires credentials per connection,
|
||||||
so verify that we're using the same name and password as well */
|
so verify that we're using the same name and password as well */
|
||||||
if(strcmp(needle->user, check->user) ||
|
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 */
|
/* one of them was different */
|
||||||
continue;
|
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
|
#ifdef USE_UNIX_SOCKETS
|
||||||
if(data->set.str[STRING_UNIX_SOCKET_PATH]) {
|
if(data->set.str[STRING_UNIX_SOCKET_PATH]) {
|
||||||
conn->unix_domain_socket = strdup(data->set.str[STRING_UNIX_SOCKET_PATH]);
|
conn->unix_domain_socket = strdup(data->set.str[STRING_UNIX_SOCKET_PATH]);
|
||||||
|
|
Loading…
Reference in New Issue