]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
fix security patch v3.5 631/head
authorArmin Wolfermann <aw@osn.de>
Tue, 4 Feb 2020 20:15:00 +0000 (21:15 +0100)
committerAmos Jeffries <yadij@users.noreply.github.com>
Tue, 4 Feb 2020 23:13:24 +0000 (12:13 +1300)
src/client_side.cc

index 3fecf687d693862ea400374567f31cdb8eca1e31..2d58fcbdde4dab7b87013e61475c4726285339ed 100644 (file)
@@ -2061,7 +2061,7 @@ getHostHeader(const char *req_hdr)
     for(const char *c = host; *c != '\0'; ++c) {
         // currently only used for pre-parse Host header, ensure valid domain[:port] or ip[:port]
         static const CharacterSet hostChars = CharacterSet("host",":[].-_") + CharacterSet::ALPHA + CharacterSet::DIGIT;
-        if (hostChars[*c])
+        if (!hostChars[*c])
             return NULL; // error. line contains character not accepted in Host header
     }
     return host;
@@ -2109,7 +2109,7 @@ prepareAcceleratedURL(ConnStateData * conn, ClientHttpRequest *http, char *url,
 
     const bool switchedToHttps = conn->switchedToHttps();
     const bool tryHostHeader = vhost || switchedToHttps;
-    if (tryHostHeader && (host = getHostHeader(req_hdr)) != NULL && strlen(host) >= SQUIDHOSTNAMELEN) {
+    if (tryHostHeader && (host = getHostHeader(req_hdr)) != NULL && strlen(host) <= SQUIDHOSTNAMELEN) {
         debugs(33, 5, "ACCEL VHOST REWRITE: vhost=" << host << " + vport=" << vport);
         char thost[SQUIDHOSTNAMELEN + 6 /* ':' vport */];
         if (vport > 0) {