mirror of
https://github.com/curl/curl.git
synced 2026-05-07 07:57:28 +03:00
peer: fix compare of hostname for uds
Unix domain socket paths need to be compared case-senstive, in contrast
to DNS hostnames.
Follow-up to bc40e09f63
Pointed out by Codex Security
Closes #21511
This commit is contained in:
parent
06839bda76
commit
455bebc2c7
1 changed files with 13 additions and 4 deletions
17
lib/peer.c
17
lib/peer.c
|
|
@ -318,15 +318,24 @@ bool Curl_peer_equal(struct Curl_peer *p1, struct Curl_peer *p2)
|
|||
Curl_peer_same_destination(p1, p2));
|
||||
}
|
||||
|
||||
static bool peer_same_hostname(struct Curl_peer *p1, struct Curl_peer *p2)
|
||||
{
|
||||
/* UNIX domain socket paths must be compared case-sensitive,
|
||||
* as many filesystem are like that. */
|
||||
return (p1->unix_socket == p2->unix_socket) &&
|
||||
(p1->abstract_uds == p2->abstract_uds) &&
|
||||
(p1->ipv6 == p2->ipv6) &&
|
||||
(p1->unix_socket ?
|
||||
!strcmp(p1->hostname, p2->hostname) :
|
||||
curl_strequal(p1->hostname, p2->hostname));
|
||||
}
|
||||
|
||||
bool Curl_peer_same_destination(struct Curl_peer *p1, struct Curl_peer *p2)
|
||||
{
|
||||
return (p1 == p2) ||
|
||||
(p1 && p2 &&
|
||||
(p1->port == p2->port) &&
|
||||
curl_strequal(p1->hostname, p2->hostname) &&
|
||||
(p1->ipv6 == p2->ipv6) &&
|
||||
(p1->unix_socket == p2->unix_socket) &&
|
||||
(p1->abstract_uds == p2->abstract_uds) &&
|
||||
peer_same_hostname(p1, p2) &&
|
||||
(p1->scopeid == p2->scopeid) &&
|
||||
(p1->scopeid || curl_strequal(p1->zoneid, p2->zoneid)));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue