From a0b240cd9f515029e1883542c1728fae7eb45a07 Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Fri, 30 Dec 2016 19:27:19 +1300 Subject: [PATCH] Detect HTTP header ACL issues rep_header and req_header ACL types cannot match multiple different headers in one test (unlike Squid-2 appears to have done). Produce an ERROR and ignore the extra line(s) instead of silently changing all the previous regex to match the second header name. Also detect and ERROR when header name is missing entirely. Ignore these lines instead of asserting. --- src/acl/HttpHeaderData.cc | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/acl/HttpHeaderData.cc b/src/acl/HttpHeaderData.cc index 52dbf162bf..ff9275c49c 100644 --- a/src/acl/HttpHeaderData.cc +++ b/src/acl/HttpHeaderData.cc @@ -75,9 +75,21 @@ void ACLHTTPHeaderData::parse() { char* t = ConfigParser::strtokFile(); - assert (t != NULL); - hdrName = t; - hdrId = Http::HeaderLookupTable.lookup(hdrName).id; + if (!t) { + debugs(28, DBG_CRITICAL, "ERROR: " << cfg_filename << " line " << config_lineno << ": " << config_input_line); + debugs(28, DBG_CRITICAL, "ERROR: Missing header name in ACL"); + return; + } + + if (hdrName.isEmpty()) { + hdrName = t; + hdrId = Http::HeaderLookupTable.lookup(hdrName).id; + } else if (hdrName.caseCmp(t) != 0) { + debugs(28, DBG_CRITICAL, "ERROR: " << cfg_filename << " line " << config_lineno << ": " << config_input_line); + debugs(28, DBG_CRITICAL, "ERROR: ACL cannot match both " << hdrName << " and " << t << " headers. Use 'anyof' ACL instead."); + return; + } + regex_rule->parse(); } -- 2.39.5