]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix protocol names in AnyP::PortCfg after http_port_list revamp in r12121.
authorAlex Rousskov <rousskov@measurement-factory.com>
Wed, 23 May 2012 23:34:49 +0000 (17:34 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Wed, 23 May 2012 23:34:49 +0000 (17:34 -0600)
The bug manifests itself when the URIs of intercepted requests are rewritten
into "https_port://..." strings, resulting in "Invalid port '0'" errors in
urlParse, followed by HTTP 400 (Bad Request) rejection.

There are other, more subtle cases where wrong PortCfg protocol matters.

src/cache_cf.cc

index c1ca4767d9704cfbe81527b01b0cb5c437695f2b..1360decf900b76fc5d63e27a9690a2783cdcf4f6 100644 (file)
@@ -3774,8 +3774,19 @@ add_http_port(char *portspec)
 }
 
 static void
-parsePortCfg(AnyP::PortCfg ** head, const char *protocol)
-{
+parsePortCfg(AnyP::PortCfg ** head, const char *optionName)
+{
+    const char *protocol = NULL;
+    if (strcmp(optionName, "http_port") == 0 ||
+        strcmp(optionName, "ascii_port") == 0)
+        protocol = "http";
+    else if (strcmp(optionName, "https_port") == 0)
+        protocol = "https";
+    if (!protocol) {
+        self_destruct();
+        return;
+    }
+
     char *token = strtok(NULL, w_space);
 
     if (!token) {