You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by lg...@apache.org on 2018/08/11 08:09:43 UTC

[2/2] mina-sshd git commit: [SSHD-840] Respond to unknown messages with SSH_MSG_UNIMPLEMENTED

[SSHD-840] Respond to unknown messages with SSH_MSG_UNIMPLEMENTED


Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/4c12a219
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/4c12a219
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/4c12a219

Branch: refs/heads/master
Commit: 4c12a21977714ab8d3f454d52c43be93a773f50f
Parents: 58209cd
Author: Robert Varga <ro...@pantheon.tech>
Authored: Sat Aug 11 10:24:49 2018 +0300
Committer: Lyor Goldstein <ly...@gmail.com>
Committed: Sat Aug 11 11:14:21 2018 +0300

----------------------------------------------------------------------
 .../session/helpers/AbstractConnectionService.java | 17 +++++++++++++++--
 .../common/session/helpers/AbstractSession.java    |  2 +-
 2 files changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/4c12a219/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java
index a0fd163..215b907 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java
@@ -368,8 +368,21 @@ public abstract class AbstractConnectionService
             case SshConstants.SSH_MSG_REQUEST_FAILURE:
                 requestFailure(buffer);
                 break;
-            default:
-                throw new IllegalStateException("Unsupported command: " + SshConstants.getCommandMessageName(cmd));
+            default: {
+                /*
+                 * According to https://tools.ietf.org/html/rfc4253#section-11.4
+                 *
+                 *      An implementation MUST respond to all unrecognized messages
+                 *      with an SSH_MSG_UNIMPLEMENTED message in the order in which
+                 *      the messages were received.
+                 */
+                AbstractSession session = getSession();
+                if (log.isDebugEnabled()) {
+                    log.debug("process({}) Unsupported command: {}",
+                        session, SshConstants.getCommandMessageName(cmd));
+                }
+                session.notImplemented();
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/4c12a219/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
index 32ef21b..b223901 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
@@ -2034,7 +2034,7 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
      * @see #sendNotImplemented(long)
      */
     protected IoWriteFuture notImplemented() throws IOException {
-        return sendNotImplemented(seqi - 1);
+        return sendNotImplemented(seqi - 1L);
     }
 
     /**