diff options
author | Christian Kandeler <christian.kandeler@theqtcompany.com> | 2014-11-26 10:46:10 +0100 |
---|---|---|
committer | hjk <hjk121@nokiamail.com> | 2014-11-26 10:50:02 +0100 |
commit | 26920307f0b481809d0179bdc007d1336794690c (patch) | |
tree | 59a29cd18ec3d6fe83553004e71af131fd1af4ed | |
parent | 050197edf38a2d879fa2122c2ec8ef2ff3342e70 (diff) | |
download | qt-creator-26920307f0b481809d0179bdc007d1336794690c.tar.gz |
SSH: Fix misleading error message.
- It is not an error if the server replies to one of our earlier
requests while we are in closing state. This can happen if we
close the channel shortly after sending the other request.
- Also change the message itself, which could be interpreted as
"packet corrupt" when we actually meant "packet unexpected".
Change-Id: I735c67b2a9b41af0c5e0b8d229369d94ec37277c
Reviewed-by: hjk <hjk121@nokiamail.com>
-rw-r--r-- | src/libs/ssh/sshchannel.cpp | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/src/libs/ssh/sshchannel.cpp b/src/libs/ssh/sshchannel.cpp index 478cbb1642..269cee765b 100644 --- a/src/libs/ssh/sshchannel.cpp +++ b/src/libs/ssh/sshchannel.cpp @@ -137,10 +137,16 @@ void AbstractSshChannel::flushSendBuffer() void AbstractSshChannel::handleOpenSuccess(quint32 remoteChannelId, quint32 remoteWindowSize, quint32 remoteMaxPacketSize) { - if (m_state != SessionRequested) { - throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, - "Invalid SSH_MSG_CHANNEL_OPEN_CONFIRMATION packet."); - } + switch (m_state) { + case SessionRequested: + break; // Ok, continue. + case CloseRequested: + return; // Late server reply; we requested a channel close in the meantime. + default: + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_MSG_CHANNEL_OPEN_CONFIRMATION packet."); + } + m_timeoutTimer->stop(); if (remoteMaxPacketSize < MinMaxPacketSize) { @@ -162,10 +168,16 @@ void AbstractSshChannel::handleOpenSuccess(quint32 remoteChannelId, void AbstractSshChannel::handleOpenFailure(const QString &reason) { - if (m_state != SessionRequested) { - throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, - "Invalid SSH_MSG_CHANNEL_OPEN_FAILURE packet."); - } + switch (m_state) { + case SessionRequested: + break; // Ok, continue. + case CloseRequested: + return; // Late server reply; we requested a channel close in the meantime. + default: + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_MSG_CHANNEL_OPEN_CONFIRMATION packet."); + } + m_timeoutTimer->stop(); #ifdef CREATOR_SSH_DEBUG |