From: Amos Jeffries Date: Thu, 30 Jun 2016 20:47:53 +0000 (+1200) Subject: Fix SEGFAULT parsing malformed adaptation service configuration X-Git-Tag: SQUID_3_5_20~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ae8371d43d0bdcaa2eb009738a4764b2ad0a8c8;p=thirdparty%2Fsquid.git Fix SEGFAULT parsing malformed adaptation service configuration 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. --- diff --git a/src/adaptation/ServiceConfig.cc b/src/adaptation/ServiceConfig.cc index 5017c068aa..cbae4d4689 100644 --- a/src/adaptation/ServiceConfig.cc +++ b/src/adaptation/ServiceConfig.cc @@ -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; }