From: Amos Jeffries Date: Sun, 5 May 2013 08:38:06 +0000 (-0600) Subject: Fix parsing error in rev.12620 X-Git-Tag: SQUID_3_4_0_1~169 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=788542bd21e01850c6b9af63a4e6effe7fbc0f25;p=thirdparty%2Fsquid.git Fix parsing error in rev.12620 The ConfigParser::strtokFile() methods added by rev.12620 use an undo mechanism to pull the next token if anything has been undone. The new parseFlags() method also added in that revision uses the undo mechanism for any token which is not a flag token it also returns the token in its nextToken parameter. In ACLIP the data parser uses parseFlags() and the nextToken received then goes on to use strtokFile() and the undo copy of that same token. The result being that all dst/src ACLs had a double-entry for the first IP address tokens. Since IP address tokens are de-duplicated with loud WARNING on -k parse this was resulting in confusing noise from the built-in ACL definitions. Since parseFlags() is so new and ACLIP was the only user of the nextToken parameter we can drop it entirely and rely on only ConfigParser undo mechanism from now on. --- diff --git a/src/acl/Acl.cc b/src/acl/Acl.cc index 2eeef57fab..bb9401f5a4 100644 --- a/src/acl/Acl.cc +++ b/src/acl/Acl.cc @@ -52,8 +52,9 @@ bool ACLFlags::supported(const ACLFlag f) const } void -ACLFlags::parseFlags(char * &nextToken) +ACLFlags::parseFlags() { + char *nextToken; while ((nextToken = ConfigParser::strtokFile()) != NULL && nextToken[0] == '-') { //if token is the "--" break flag @@ -235,8 +236,7 @@ ACL::ParseAclLine(ConfigParser &parser, ACL ** head) */ AclMatchedName = A->name; /* ugly */ - char *aTok; - A->flags.parseFlags(aTok); + A->flags.parseFlags(); /*split the function here */ A->parse(); diff --git a/src/acl/Acl.h b/src/acl/Acl.h index 4c8613fbf8..a7dc67f18c 100644 --- a/src/acl/Acl.h +++ b/src/acl/Acl.h @@ -70,8 +70,8 @@ public: void makeSet(const ACLFlag f) { flags_ |= flagToInt(f); } ///< Set the given flag /// Return true if the given flag is set bool isSet(const ACLFlag f) const { return flags_ & flagToInt(f);} - /// Parse a flags given in the form -[A..Z|a..z] - void parseFlags(char * &nextToken); + /// Parse optional flags given in the form -[A..Z|a..z] + void parseFlags(); const char *flagsStr() const; ///< Convert the flags to a string representation private: diff --git a/src/acl/Ip.cc b/src/acl/Ip.cc index ab0c808b04..2eda58b2f1 100644 --- a/src/acl/Ip.cc +++ b/src/acl/Ip.cc @@ -507,14 +507,9 @@ acl_ip_data::FactoryParse(const char *t) void ACLIP::parse() { - char *t = NULL; + flags.parseFlags(); - flags.parseFlags(t); - - if (!t) - return; - - do { + while (char *t = strtokFile()) { acl_ip_data *q = acl_ip_data::FactoryParse(t); while (q != NULL) { @@ -524,7 +519,7 @@ ACLIP::parse() data = data->insert(q, acl_ip_data::NetworkCompare); q = next_node; } - } while ((t = strtokFile())); + } } ACLIP::~ACLIP()