]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Deleting first fs left psstate->servers pointing to uninitialized memory
authorChristos Tsantilas <chtsanti@users.sourceforge.net>
Thu, 18 Dec 2014 14:36:23 +0000 (06:36 -0800)
committerAmos Jeffries <squid3@treenet.co.nz>
Thu, 18 Dec 2014 14:36:23 +0000 (06:36 -0800)
 ... possibly causing infinite loops in peerAddFwdServer().

TODO: The condition itself is excessive. If fs is not nil, the previous check
already tells us that the Config.forward_max_tries limit is exceeded.

src/peer_select.cc

index 19e337105a6171af3eaca6253c4767217bba20a0..9c26a20c57af8c2fc3d425d54c7b4572e0c38046 100644 (file)
@@ -271,11 +271,12 @@ peerSelectDnsPaths(ps_state *psstate)
     // due to the allocation method of fs, we must deallocate each manually.
     // TODO: use a std::list so we can get the size and abort adding whenever the selection loops reach Config.forward_max_tries
     if (fs && psstate->paths->size() >= (unsigned int)Config.forward_max_tries) {
+        assert(fs == psstate->servers);
         while (fs) {
-            FwdServer *next = fs->next;
+            psstate->servers = fs->next;
             cbdataReferenceDone(fs->_peer);
             memFree(fs, MEM_FWD_SERVER);
-            fs = next;
+            fs = psstate->servers;
         }
     }