]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Convert hostname_aliases to SBufList (#1737)
authorAmos Jeffries <yadij@users.noreply.github.com>
Fri, 15 Mar 2024 13:24:27 +0000 (13:24 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Fri, 15 Mar 2024 13:24:31 +0000 (13:24 +0000)
Fix a bug where hostname_aliases was being
compared case-sensitively with HTTP request
Host / URL domain.

src/SquidConfig.h
src/cf.data.pre
src/client_side_request.cc
src/internal.cc
src/internal.h

index b3d3bb541eb3b634c1b97ea4d08f2359c556e91d..83063220ade36d4101ed8570743fc676bc3c4eb7 100644 (file)
@@ -227,7 +227,7 @@ public:
     char *etcHostsPath;
     char *visibleHostname;
     char *uniqueHostname;
-    wordlist *hostnameAliases;
+    SBufList hostnameAliases;
     char *errHtmlText;
 
     struct {
index 15fe637ec080dfe1b47a3ccc7b4ede2321219cc7..644899e67698240866c086da8e7399f11fd8da1e 100644 (file)
@@ -7602,7 +7602,7 @@ DOC_START
 DOC_END
 
 NAME: hostname_aliases
-TYPE: wordlist
+TYPE: SBufList
 LOC: Config.hostnameAliases
 DEFAULT: none
 DOC_START
index b80b1b23057b6e5f60a76222ba37dd43c7272d83..9ed54f2c7261edf9c61b1b8314f14b250502c97e 100644 (file)
@@ -1662,7 +1662,7 @@ ClientHttpRequest::checkForInternalAccess()
     if (!internalCheck(request->url.path()))
         return;
 
-    if (internalHostnameIs(request->url.host()) && request->url.port() == getMyPort()) {
+    if (request->url.port() == getMyPort() && internalHostnameIs(SBuf(request->url.host()))) {
         debugs(33, 3, "internal URL found: " << request->url.getScheme() << "://" << request->url.authority(true));
         request->flags.internal = true;
     } else if (Config.onoff.global_internal_static && internalStaticCheck(request->url.path())) {
index 6766f3bd2365c69268890dce284bbed7ec173707..326b175bc0c6cd74078d8e02220315ccdc6602e0 100644 (file)
@@ -23,7 +23,6 @@
 #include "Store.h"
 #include "tools.h"
 #include "util.h"
-#include "wordlist.h"
 
 /* called when we "miss" on an internal object;
  * generate known dynamic objects,
@@ -162,18 +161,17 @@ internalHostname(void)
     return host;
 }
 
-int
-internalHostnameIs(const char *arg)
+bool
+internalHostnameIs(const SBuf &arg)
 {
-    wordlist *w;
-
-    if (0 == strcmp(arg, internalHostname()))
-        return 1;
+    if (arg.caseCmp(internalHostname()) == 0)
+        return true;
 
-    for (w = Config.hostnameAliases; w; w = w->next)
-        if (0 == strcmp(arg, w->key))
-            return 1;
+    for (const auto &w : Config.hostnameAliases) {
+        if (w.caseCmp(arg) == 0)
+            return true;
+    }
 
-    return 0;
+    return false;
 }
 
index 0bb628f1d38a6e4932ecd5813fb0769d131b14dc..c0cd7b246062fbb592e936c244b2231e57b5eba3 100644 (file)
@@ -27,7 +27,7 @@ bool internalStaticCheck(const SBuf &urlPath);
 char *internalLocalUri(const char *dir, const SBuf &name);
 char *internalRemoteUri(bool, const char *, unsigned short, const char *, const SBuf &);
 const char *internalHostname(void);
-int internalHostnameIs(const char *);
+bool internalHostnameIs(const SBuf &);
 
 /// whether the given request URL path points to a cache manager (not
 /// necessarily running on this Squid instance)