httpsrr+ech: check target and port
No binary (build failed)
—
(log yok)
| @@ -239,11 +239,19 @@ void Curl_httpsrr_destroy(struct Curl_https_rrinfo *rrinfo) | |
| bool Curl_httpsrr_applicable(struct Curl_easy *data, | |
| const struct Curl_https_rrinfo *rr) | |
| { | |
| - | if(!data->conn || !rr) |
| + | if(!data->conn) |
| + | return FALSE; |
| + | return Curl_httpsrr_is_for_peer(data->conn->origin, rr); |
| + | } |
| + | |
| + | bool Curl_httpsrr_is_for_peer(struct Curl_peer *peer, |
| + | const struct Curl_https_rrinfo *rr) |
| + | { |
| + | if(!peer || !rr) |
| return FALSE; | |
| return (!rr->target || !rr->target[0] || | |
| (rr->target[0] == '.' && !rr->target[1])) && | |
| - | (!rr->port_set || rr->port == data->conn->origin->port); |
| + | (!rr->port_set || rr->port == peer->port); |
| } | |
| #ifdef USE_ARES | |
| @@ -67,6 +67,10 @@ void Curl_httpsrr_destroy(struct Curl_https_rrinfo *rrinfo); | |
| bool Curl_httpsrr_applicable(struct Curl_easy *data, | |
| const struct Curl_https_rrinfo *rr); | |
| + | /* TRUE if the record is applicable to the given peer. */ |
| + | bool Curl_httpsrr_is_for_peer(struct Curl_peer *peer, |
| + | const struct Curl_https_rrinfo *rr); |
| + | |
| /* | |
| * Code points for DNS wire format SvcParams as per RFC 9460 | |
| */ | |
| @@ -3527,7 +3527,7 @@ static CURLcode ossl_init_ech(struct ossl_ctx *octx, | |
| const struct Curl_https_rrinfo *rinfo = | |
| Curl_conn_dns_get_https(data, cf->sockindex, peer->origin); | |
| - | if(rinfo && rinfo->echconfiglist) { |
| + | if(Curl_httpsrr_is_for_peer(peer->origin, rinfo) && rinfo->echconfiglist) { |
| const unsigned char *ecl = rinfo->echconfiglist; | |
| size_t elen = rinfo->echconfiglist_len; | |
| @@ -984,7 +984,8 @@ init_config_builder_ech(struct Curl_easy *data, | |
| const struct Curl_https_rrinfo *rinfo = | |
| Curl_conn_dns_get_https(data, cf->sockindex, connssl->peer.origin); | |
| - | if(!rinfo || !rinfo->echconfiglist) { |
| + | if(!Curl_httpsrr_is_for_peer(connssl->peer.origin, rinfo) || |
| + | !rinfo->echconfiglist) { |
| failf(data, "rustls: ECH requested but no ECHConfig available"); | |
| result = CURLE_SSL_CONNECT_ERROR; | |
| goto cleanup; | |
| @@ -1277,7 +1277,7 @@ static CURLcode wssl_init_ech(struct wssl_ctx *wctx, | |
| const struct Curl_https_rrinfo *rinfo = | |
| Curl_conn_dns_get_https(data, cf->sockindex, peer->origin); | |
| - | if(rinfo && rinfo->echconfiglist) { |
| + | if(Curl_httpsrr_is_for_peer(peer->origin, rinfo) && rinfo->echconfiglist) { |
| const unsigned char *ecl = rinfo->echconfiglist; | |
| size_t elen = rinfo->echconfiglist_len; | |