From: Jay Satiro Date: Tue, 3 Dec 2024 20:56:07 +0000 (-0500) Subject: hostip: don't use the resolver for FQDN localhost X-Git-Tag: curl-8_11_1~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a4458c7ee369a4d789168669d6efdf364bb9fb97;p=thirdparty%2Fcurl.git hostip: don't use the resolver for FQDN localhost - Treat `[.]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 `.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 --- diff --git a/lib/hostip.c b/lib/hostip.c index fe8cc5cb97..1a9432d52a 100644 --- a/lib/hostip.c +++ b/lib/hostip.c @@ -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)