From: Alex Rousskov Date: Fri, 23 Aug 2013 23:34:28 +0000 (-0600) Subject: Avoid segfaults when RETR is not preceded by PORT or PASV. X-Git-Tag: SQUID_3_5_0_1~117^2~56 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=800113dac29188945008f6e5d70c7fcb989fa6b4;p=thirdparty%2Fsquid.git Avoid segfaults when RETR is not preceded by PORT or PASV. Polished code. --- diff --git a/src/client_side.cc b/src/client_side.cc index e84f2cef43..b83e3cb6e1 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -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)); }