1
0
mirror of https://github.com/winscp/winscp.git synced 2026-10-24 02:28:55 +03:00

Bug 2077: Improve error message when FTP server returns malformed response

https://winscp.net/tracker/2077

Source commit: fcf4ac3e67bfc4f877167881157278f1e28650db
This commit is contained in:
Martin Prikryl
2022-05-20 08:33:19 +00:00
parent 9d1de54c92
commit cee1be5d62
3 changed files with 9 additions and 1 deletions

View File

@@ -1532,10 +1532,16 @@ int CFtpControlSocket::GetReplyCode()
if (m_RecvBuffer.empty())
return 0;
CStringA str = m_RecvBuffer.front();
if (str == "")
if ((str == "") || (str[0] < '1') || (str[0] > '9'))
{
UnicodeString Error = FMTLOAD(FTP_MALFORMED_RESPONSE, (UnicodeString(str)));
LogMessageRaw(FZ_LOG_WARNING, Error.c_str());
return 0;
}
else
{
return str[0]-'0';
}
}
void CFtpControlSocket::DoClose(int nError /*=0*/)

View File

@@ -278,6 +278,7 @@
#define CREATE_TEMP_DIR_ERROR 754
#define OPENSSH_CONFIG_NOT_FOUND 755
#define OPENSSH_CONFIG_NO_SITES 756
#define FTP_MALFORMED_RESPONSE 757
#define CORE_CONFIRMATION_STRINGS 300
#define CONFIRM_PROLONG_TIMEOUT3 301

View File

@@ -250,6 +250,7 @@ BEGIN
CREATE_TEMP_DIR_ERROR, "Cannot create temporary directory '%s'. You may change root directory to store temporary files in Preferences."
OPENSSH_CONFIG_NOT_FOUND, "OpenSSH config file not found."
OPENSSH_CONFIG_NO_SITES, "No Host directives for specific hosts found in OpenSSH config file."
FTP_MALFORMED_RESPONSE, "FTP server returned invalid response '%s'."
CORE_CONFIRMATION_STRINGS, "CORE_CONFIRMATION"
CONFIRM_PROLONG_TIMEOUT3, "Host is not communicating for %d seconds.\n\nWait for another %0:d seconds?"