]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix splay-related issues
authorFrancesco Chemolli <kinkie@squid-cache.org>
Tue, 6 Jan 2015 21:05:37 +0000 (22:05 +0100)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Tue, 6 Jan 2015 21:05:37 +0000 (22:05 +0100)
In several cases Splay data membes would not be properly initialized in ACL and MemPools code
A duplicate IP ACL value would cause an assert.

include/splay.h
src/acl/Arp.cc
src/acl/Eui64.cc
src/acl/HttpStatus.cc
src/acl/Ip.cc
src/acl/StringData.cc
src/acl/UserData.cc
src/mem/PoolChunked.cc

index 2119e501ee600b4c6251c564fe1a772252c4ed91..acf42709ea0ec9c51cc3bb0f9c20f511344ffced 100644 (file)
@@ -299,7 +299,7 @@ template <class V>
 void
 Splay<V>::insert(Value const &value, SPLAYCMP *compare)
 {
-    assert (!find (value, compare));
+    assert (find (value, compare) == NULL);
     if (head == NULL)
         head = new SplayNode<V>(value);
     else
index 5eae6100b432d78ad9ccd9e37f5de87599c8785c..08b3c092563b8ee509104483c9a3fa1e8fa9b676 100644 (file)
@@ -114,6 +114,8 @@ aclParseArpData(const char *t)
 void
 ACLARP::parse()
 {
+    if (!data)
+        data = new Splay<Eui::Eui48 *>();
     aclParseArpList(&data);
 }
 
index d18e73a4fe8e3786c57d5bce01edb89e644a08c7..14b08d2d88c39b6d60616890a59e761ebdebc533 100644 (file)
@@ -88,6 +88,8 @@ aclParseEuiData(const char *t)
 void
 ACLEui64::parse()
 {
+    if (!data)
+        data = new Splay<Eui::Eui64 *>();
     aclParseEuiList(&data);
 }
 
index d83d7de4dc348ff5122d08b8ec9663b9c0bfc47f..a62c6e4ee29f1ff60c5e3da40d53ce78f5745091 100644 (file)
@@ -111,6 +111,9 @@ aclParseHTTPStatusData(const char *t)
 void
 ACLHTTPStatus::parse()
 {
+    if (!data)
+        data = new Splay<acl_httpstatus_data*>();
+
     aclParseHTTPStatusList (&data);
 }
 
index 7fc37a9b5b734632b781e66bfa797bfaf73b03dc..0b8ad879515d92b00c36bf6b85214cb3cc69c59c 100644 (file)
@@ -485,7 +485,8 @@ ACLIP::parse()
             /* pop each result off the list and add it to the data tree individually */
             acl_ip_data *next_node = q->next;
             q->next = NULL;
-            data->insert(q, acl_ip_data::NetworkCompare);
+            if (!data->find(q,acl_ip_data::NetworkCompare))
+                data->insert(q, acl_ip_data::NetworkCompare);
             q = next_node;
         }
     }
index 7775b7cfd9069ed423229465d2572fd229e0d729..f5cac0be7b31ef88576459f848f2d8944b2245e3 100644 (file)
@@ -83,8 +83,10 @@ ACLStringData::dump() const
 void
 ACLStringData::parse()
 {
-    char *t;
+    if (!values)
+        values = new Splay<char *>();
 
+    char *t;
     while ((t = strtokFile()))
         values->insert(xstrdup(t), splaystrcmp);
 }
index 28af6dc36d6bc2eb0c54a7f621ca64dd7625783c..8a59acfe28f20968b31eb1951556d6841a905795 100644 (file)
@@ -102,8 +102,11 @@ void
 ACLUserData::parse()
 {
     debugs(28, 2, "aclParseUserList: parsing user list");
-    char *t = NULL;
 
+    if (!names)
+        names = new Splay<char *>();
+
+    char *t = NULL;
     if ((t = ConfigParser::strtokFile())) {
         debugs(28, 5, "aclParseUserList: First token is " << t);
 
index 6ed4017dcef77498bd803474089b55315c28d0e0..abbd17ddd00b3f93f1a7059aaea54295152db5f0 100644 (file)
@@ -135,16 +135,11 @@ MemChunk::MemChunk(MemPoolChunked *aPool)
     pool->allChunks.insert(this, memCompChunks);
 }
 
-MemPoolChunked::MemPoolChunked(const char *aLabel, size_t aSize) : MemImplementingAllocator(aLabel, aSize)
+MemPoolChunked::MemPoolChunked(const char *aLabel, size_t aSize) :
+                MemImplementingAllocator(aLabel, aSize) , chunk_size(0),
+                chunk_capacity(0), chunkCount(0), freeCache(0), nextFreeChunk(0),
+                Chunks(0), allChunks(Splay<MemChunk *>())
 {
-    chunk_size = 0;
-    chunk_capacity = 0;
-    chunkCount = 0;
-    freeCache = 0;
-    nextFreeChunk = 0;
-    Chunks = 0;
-    next = 0;
-
     setChunkSize(MEM_CHUNK_SIZE);
 
 #if HAVE_MALLOPT && M_MMAP_MAX