]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 4208: more than one port in wccp2_service_info line causes error
authorGuy Helmer <ghelmer@palisadesys.com>
Fri, 25 Sep 2015 23:16:48 +0000 (16:16 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 25 Sep 2015 23:16:48 +0000 (16:16 -0700)
src/wccp2.cc

index 36317344d9627d7e02e945b44718ab6c7efa08d6..01cc818b95bcfe17f8ea0f4c00f3730d689a3f9a 100644 (file)
@@ -2234,12 +2234,19 @@ parse_wccp2_service_ports(char *options, int portlist[])
 
     int i = 0;
     char *tmp = options;
+    static char copy[10];
 
     while (size_t len = strcspn(tmp, ",")) {
         if (i >= WCCP2_NUMPORTS) {
             fatalf("parse_wccp2_service_ports: too many ports (maximum: 8) in list '%s'\n", options);
         }
-        int p = xatoi(tmp);
+        if (len > 6) { // 6 because "65535,"
+            fatalf("parse_wccp2_service_ports: port value '%s' isn't valid (1..65535)\n", tmp);
+        }
+
+        memcpy(copy, tmp, len);
+        copy[len] = '\0';
+        int p = xatoi(copy);
 
         if (p < 1 || p > 65535) {
             fatalf("parse_wccp2_service_ports: port value '%s' isn't valid (1..65535)\n", tmp);