cf-https-connect: use the passed in dns struct pointer

... instead of digging it out from the connection struct.

Plus: simplify struct referencing in the condition.

Closes #17092
This commit is contained in:
Daniel Stenberg 2025-04-17 22:49:29 +02:00
parent 834836dc14
commit 1102ea9f4b
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View file

@ -664,22 +664,22 @@ CURLcode Curl_cf_https_setup(struct Curl_easy *data,
if(conn->bits.tls_enable_alpn) {
#ifdef USE_HTTPSRR
/* Is there a HTTPSRR and if so, do its ALPNs it apply here?
/* Is there a HTTPSRR use its ALPNs here.
* We are here after having selected a connection to a host+port and
* can no longer change that. Any HTTPSRR advice for other hosts and ports
* we need to ignore. */
if(conn->dns_entry && conn->dns_entry->hinfo &&
!conn->dns_entry->hinfo->no_def_alpn && /* ALPNs are defaults */
(!conn->dns_entry->hinfo->target || /* for same host */
!conn->dns_entry->hinfo->target[0] ||
(conn->dns_entry->hinfo->target[0] == '.' &&
!conn->dns_entry->hinfo->target[1])) &&
(conn->dns_entry->hinfo->port < 0 || /* for same port */
conn->dns_entry->hinfo->port == conn->remote_port)) {
struct Curl_https_rrinfo *rr = remotehost ? remotehost->hinfo : NULL;
if(rr && !rr->no_def_alpn && /* ALPNs are defaults */
(!rr->target || /* for same host */
!rr->target[0] ||
(rr->target[0] == '.' &&
!rr->target[1])) &&
(rr->port < 0 || /* for same port */
rr->port == conn->remote_port)) {
size_t i;
for(i = 0; i < CURL_ARRAYSIZE(conn->dns_entry->hinfo->alpns) &&
for(i = 0; i < CURL_ARRAYSIZE(rr->alpns) &&
alpn_count < CURL_ARRAYSIZE(alpn_ids); ++i) {
enum alpnid alpn = conn->dns_entry->hinfo->alpns[i];
enum alpnid alpn = rr->alpns[i];
if(cf_https_alpns_contain(alpn, alpn_ids, alpn_count))
continue;
switch(alpn) {