From: Amos Jeffries Date: Fri, 10 Jun 2016 09:09:57 +0000 (+1200) Subject: Fix SEGFAULT parsing malformed adaptation service configuration X-Git-Tag: SQUID_4_0_12~28 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c120c307e0a1dc2ab8cd0137b49ec57228d03f9f;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 1aa63eefbe..f35df17600 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; } @@ -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; }