]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix SEGFAULT parsing malformed adaptation service configuration
authorAmos Jeffries <squid3@treenet.co.nz>
Fri, 10 Jun 2016 09:09:57 +0000 (21:09 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 10 Jun 2016 09:09:57 +0000 (21:09 +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 1aa63eefbe45dbd35b0a518cbdb0e808929ebd16..f35df1760052db4e945b287cf2d8bde445ff3fa4 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;
         }
@@ -160,7 +171,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;
     }