]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix parsing error in rev.12620
authorAmos Jeffries <squid3@treenet.co.nz>
Sun, 5 May 2013 08:38:06 +0000 (02:38 -0600)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 5 May 2013 08:38:06 +0000 (02:38 -0600)
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.

src/acl/Acl.cc
src/acl/Acl.h
src/acl/Ip.cc

index 2eeef57fab252947d184e738bf353b902f68aebb..bb9401f5a438327467ff28462694a3ededa8e900 100644 (file)
@@ -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();
index 4c8613fbf861c873393a493bad17e89657767a33..a7dc67f18c8c8d7164be7d13c12b99617025be05 100644 (file)
@@ -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:
index ab0c808b040f6c842472fc364984ae496c6f3d18..2eda58b2f1829170fda355888c3959a61898859f 100644 (file)
@@ -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()