hostip: don't use the resolver for FQDN localhost

- Treat `[<any>.]localhost.` (ie localhost with FQDN period terminator)
  as fixed value 127.0.0.1 and ::1 instead of querying the resolver.

Prior to this change, b5c0fe20 (precedes 7.85.0) did the same for
non-FQDN `<any>.localhost`.

Prior to this change, 1a0ebf66 (precedes 7.78.0) did the same for
non-FQDN `localhost`.

Ref: https://github.com/curl/curl/issues/15628#issuecomment-2515540315

Closes https://github.com/curl/curl/pull/15676
This commit is contained in:
Jay Satiro 2024-12-03 15:56:07 -05:00
parent 6755ba593c
commit a4458c7ee3

View File

@ -798,7 +798,9 @@ enum resolve_t Curl_resolv(struct Curl_easy *data,
return CURLRESOLV_ERROR;
if(strcasecompare(hostname, "localhost") ||
tailmatch(hostname, ".localhost"))
strcasecompare(hostname, "localhost.") ||
tailmatch(hostname, ".localhost") ||
tailmatch(hostname, ".localhost."))
addr = get_localhost(port, hostname);
#ifndef CURL_DISABLE_DOH
else if(allowDOH && data->set.doh && !ipnum)