]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix SEGFAULT parsing malformed adaptation service configuration
authorAmos Jeffries <squid3@treenet.co.nz>
Thu, 30 Jun 2016 20:47:53 +0000 (08:47 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Thu, 30 Jun 2016 20:47:53 +0000 (08:47 +1200)
icap_service or ecap_service directives with missing field values need to
abort cleanly with an error.

Also, fix config parsing error messages in adaptation service parse to
use "ERROR:" prefix consistent with squid.conf general behaviour.

src/adaptation/ServiceConfig.cc

index 5017c068aafe5df5e768fc2e3f0c2718750edc27..cbae4d46891ef2015be32fe2697148186b72c8a9 100644 (file)
@@ -69,8 +69,19 @@ Adaptation::ServiceConfig::parse()
 {
     key = ConfigParser::NextToken();
     String method_point = ConfigParser::NextToken();
+    if (!method_point.size()) {
+        debugs(3, DBG_CRITICAL, "ERROR: " << cfg_filename << ':' << config_lineno << ": " <<
+               "Missing vectoring point in adaptation service definition");
+        return false;
+    }
+
     method = parseMethod(method_point.termedBuf());
     point = parseVectPoint(method_point.termedBuf());
+    if (method == Adaptation::methodNone && point == Adaptation::pointNone) {
+        debugs(3, DBG_CRITICAL, "ERROR: " << cfg_filename << ':' << config_lineno << ": " <<
+               "Unknown vectoring point '" << method_point << "' in adaptation service definition");
+        return false;
+    }
 
     // reset optional parameters in case we are reconfiguring
     bypass = routing = false;
@@ -105,7 +116,7 @@ Adaptation::ServiceConfig::parse()
 
         // Check if option is set twice
         if (options.find(name) != options.end()) {
-            debugs(3, DBG_CRITICAL, cfg_filename << ':' << config_lineno << ": " <<
+            debugs(3, DBG_CRITICAL, "ERROR: " << cfg_filename << ':' << config_lineno << ": " <<
                    "Duplicate option \"" << name << "\" in adaptation service definition");
             return false;
         }
@@ -140,7 +151,7 @@ Adaptation::ServiceConfig::parse()
 
     // is the service URI set?
     if (!grokkedUri) {
-        debugs(3, DBG_CRITICAL, cfg_filename << ':' << config_lineno << ": " <<
+        debugs(3, DBG_CRITICAL, "ERROR: " << cfg_filename << ':' << config_lineno << ": " <<
                "No \"uri\" option in adaptation service definition");
         return false;
     }