]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Avoid FwdState::serverConn while establishing a CONNECT tunnel (#681)
authorAlex Rousskov <rousskov@measurement-factory.com>
Thu, 25 Jun 2020 09:39:45 +0000 (09:39 +0000)
committerAmos Jeffries <yadij@users.noreply.github.com>
Sat, 27 Jun 2020 14:32:05 +0000 (02:32 +1200)
Master/v6 commit 25b0ce4 missed two cases where serverConnection() was
used prematurely: One case requires --enable-delay-pools, and the other
does not actually dereference the prematurely used serverConnection().
Both cases establish a CONNECT tunnel through a cache_peer.

src/FwdState.cc

index c468541b505683c3a209979e508fc6afca972053..a992dc547783072b21ac29b5df7d7fd6151652fd 100644 (file)
@@ -133,6 +133,7 @@ void
 FwdState::closeServerConnection(const char *reason)
 {
     debugs(17, 3, "because " << reason << "; " << serverConn);
+    assert(Comm::IsConnOpen(serverConn));
     comm_remove_close_handler(serverConn->fd, closeHandler);
     closeHandler = NULL;
     fwdPconnPool->noteUses(fd_table[serverConn->fd].pconn.uses);
@@ -848,15 +849,16 @@ FwdState::establishTunnelThruProxy(const Comm::ConnectionPointer &conn)
                                             "FwdState::tunnelEstablishmentDone",
                                             Http::Tunneler::CbDialer<FwdState>(&FwdState::tunnelEstablishmentDone, this));
     HttpRequest::Pointer requestPointer = request;
-    const auto tunneler = new Http::Tunneler(conn, requestPointer, callback, connectingTimeout(serverConnection()), al);
+    const auto tunneler = new Http::Tunneler(conn, requestPointer, callback, connectingTimeout(conn), al);
 
     // TODO: Replace this hack with proper Comm::Connection-Pool association
     // that is not tied to fwdPconnPool and can handle disappearing pools.
     tunneler->noteFwdPconnUse = true;
 
 #if USE_DELAY_POOLS
-    Must(serverConnection()->getPeer());
-    if (!serverConnection()->getPeer()->options.no_delay)
+    Must(conn);
+    Must(conn->getPeer());
+    if (!conn->getPeer()->options.no_delay)
         tunneler->setDelayId(entry->mem_obj->mostBytesAllowed());
 #endif
     AsyncJob::Start(tunneler);