]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Avoid segfaults when RETR is not preceded by PORT or PASV.
authorAlex Rousskov <rousskov@measurement-factory.com>
Fri, 23 Aug 2013 23:34:28 +0000 (17:34 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Fri, 23 Aug 2013 23:34:28 +0000 (17:34 -0600)
Polished code.

src/client_side.cc

index e84f2cef43b7743e614874c4a8352ba694be01aa..b83e3cb6e1324a2e83cb549fe6039fcc3ebb9cab 100644 (file)
@@ -5604,9 +5604,9 @@ FtpCheckDataConnection(ClientSocketContext *context)
         return false;
     }
 
-    if (connState->ftp.dataConn->remote.IsAnyAddr()) {
+    if (!connState->ftp.dataConn || connState->ftp.dataConn->remote.IsAnyAddr()) {
         // XXX: use client address and default port instead.
-        FtpSetReply(context, 425, "Use PORT first");
+        FtpSetReply(context, 425, "Use PORT or PASV first");
         return false;
     }
 
@@ -5633,7 +5633,7 @@ FtpHandleConnectDone(const Comm::ConnectionPointer &conn, comm_err_t status, int
         FtpSetReply(context, 425, "Cannot open data connection.");
         assert(context->http && context->http->storeEntry() != NULL);
     } else {
-        context->getConn()->ftp.dataConn = conn;
+        assert(context->getConn()->ftp.dataConn == conn);
         context->getConn()->ftp.uploadAvailSize = 0;
         assert(Comm::IsConnOpen(context->getConn()->ftp.dataConn));
     }