From 339a6fdd59b547ea8edc5685f1dc51c5a486db04 Mon Sep 17 00:00:00 2001 From: Michal Novotny Date: Wed, 23 Nov 2011 02:11:39 +0100 Subject: [PATCH] Bug 477635 - 'blind' download ftp folder inaccessible since 3.0.5 ~ 3.0.6 - 550 PWD --- netwerk/protocol/ftp/nsFtpConnectionThread.cpp | 15 ++++++++++++--- netwerk/protocol/ftp/nsFtpConnectionThread.h | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/netwerk/protocol/ftp/nsFtpConnectionThread.cpp b/netwerk/protocol/ftp/nsFtpConnectionThread.cpp index 1c6db7b11a88..34c9998c3f73 100644 --- a/netwerk/protocol/ftp/nsFtpConnectionThread.cpp +++ b/netwerk/protocol/ftp/nsFtpConnectionThread.cpp @@ -107,6 +107,7 @@ nsFtpState::nsFtpState() , mStorReplyReceived(false) , mInternalError(NS_OK) , mReconnectAndLoginAgain(false) + , mCacheConnection(true) , mPort(21) , mAddressChecked(false) , mServerIsIPv6(false) @@ -853,8 +854,11 @@ nsFtpState::S_pwd() { FTP_STATE nsFtpState::R_pwd() { - if (mResponseCode/100 != 2) - return FTP_ERROR; + // Error response to PWD command isn't fatal, but don't cache the connection + // if CWD command is sent since correct mPwd is needed for further requests. + if (mResponseCode/100 != 2) + return FTP_S_TYPE; + nsCAutoString respStr(mResponseMsg); PRInt32 pos = respStr.FindChar('"'); if (pos > -1) { @@ -975,6 +979,10 @@ nsFtpState::R_type() { nsresult nsFtpState::S_cwd() { + // Don't cache the connection if PWD command failed + if (mPwd.IsEmpty()) + mCacheConnection = PR_FALSE; + nsCAutoString cwdStr; if (mAction != PUT) cwdStr = mPath; @@ -1815,7 +1823,8 @@ nsFtpState::KillControlConnection() if (NS_SUCCEEDED(mInternalError) && NS_SUCCEEDED(mControlStatus) && - mControlConnection->IsAlive()) { + mControlConnection->IsAlive() && + mCacheConnection) { LOG_ALWAYS(("FTP:(%p) caching CC(%p)", this, mControlConnection.get())); diff --git a/netwerk/protocol/ftp/nsFtpConnectionThread.h b/netwerk/protocol/ftp/nsFtpConnectionThread.h index 5c2641fa81e8..daf6fc6af4d0 100644 --- a/netwerk/protocol/ftp/nsFtpConnectionThread.h +++ b/netwerk/protocol/ftp/nsFtpConnectionThread.h @@ -269,6 +269,7 @@ private: // completion status from server nsresult mInternalError; // represents internal state errors bool mReconnectAndLoginAgain; + bool mCacheConnection; // ****** URI vars PRInt32 mPort; // the port to connect to