]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
hostip: don't use the resolver for FQDN localhost
authorJay Satiro <raysatiro@yahoo.com>
Tue, 3 Dec 2024 20:56:07 +0000 (15:56 -0500)
committerJay Satiro <raysatiro@yahoo.com>
Thu, 5 Dec 2024 22:16:34 +0000 (17:16 -0500)
- 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

lib/hostip.c

index fe8cc5cb97fd48652f7ff741cc58663d7b0bdf57..1a9432d52afa89cb17bddb96ce8f4a680e2d093f 100644 (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)