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 2016/03/01 05:05:24 UTC

[1/2] mina-sshd git commit: Fixed correct restore of buffer read position in case of multi-line server identification

Repository: mina-sshd
Updated Branches:
  refs/heads/master 711ae6c91 -> a151b7e65


Fixed correct restore of buffer read position in case of multi-line server identification


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

Branch: refs/heads/master
Commit: 242f42263fa3da7dc48fd991e110896649f77cd7
Parents: 711ae6c
Author: Lyor Goldstein <ly...@gmail.com>
Authored: Tue Mar 1 06:05:44 2016 +0200
Committer: Lyor Goldstein <ly...@gmail.com>
Committed: Tue Mar 1 06:05:44 2016 +0200

----------------------------------------------------------------------
 .../common/session/helpers/AbstractSession.java    | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/242f4226/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 d33253d..1fc6f9e 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
@@ -1398,11 +1398,10 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
         int maxIdentSize = PropertyResolverUtils.getIntProperty(this,
                 FactoryManager.MAX_IDENTIFICATION_SIZE, FactoryManager.DEFAULT_MAX_IDENTIFICATION_SIZE);
         List<String> ident = null;
+        int rpos = buffer.rpos();
         for (byte[] data = new byte[MAX_VERSION_LINE_LENGTH];;) {
-            int rpos = buffer.rpos();
-            int pos = 0;
-            boolean needLf = false;
-            for (;;) {
+            int pos = 0;    // start accumulating line from scratch
+            for (boolean needLf = false;;) {
                 if (buffer.available() == 0) {
                     // Need more data, so undo reading and return null
                     buffer.rpos(rpos);
@@ -1416,7 +1415,8 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
                  *      "The null character MUST NOT be sent"
                  */
                 if (b == 0) {
-                    throw new IllegalStateException("Incorrect identification (null characters not allowed) - after " + new String(data, 0, pos, StandardCharsets.UTF_8));
+                    throw new IllegalStateException("Incorrect identification (null characters not allowed) - after "
+                            + new String(buffer.array(), rpos, buffer.rpos(), StandardCharsets.UTF_8));
                 }
                 if (b == '\r') {
                     needLf = true;
@@ -1428,7 +1428,8 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
                 }
 
                 if (needLf) {
-                    throw new IllegalStateException("Incorrect identification (bad line ending): " + new String(data, 0, pos, StandardCharsets.UTF_8));
+                    throw new IllegalStateException("Incorrect identification (bad line ending): "
+                            + new String(buffer.array(), rpos, buffer.rpos(), StandardCharsets.UTF_8));
                 }
 
                 if (pos >= data.length) {
@@ -1448,13 +1449,13 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
             }
             ident.add(str);
 
-            // if this is a server then only one line is expected
+            // if this is a server then only one line is expected from the client
             if (server || str.startsWith("SSH-")) {
                 return ident;
             }
 
             if (buffer.rpos() > maxIdentSize) {
-                throw new IllegalStateException("Incorrect identification: too many header lines - size > " + maxIdentSize);
+                throw new IllegalStateException("Incorrect identification (too many header lines): size > " + maxIdentSize);
             }
         }
     }


[2/2] mina-sshd git commit: Restored correct timeouts in ServerTest#testMultiLineServerIdentification

Posted by lg...@apache.org.
Restored correct timeouts in ServerTest#testMultiLineServerIdentification


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

Branch: refs/heads/master
Commit: a151b7e656814b05b36ed675864479280956c24a
Parents: 242f422
Author: Lyor Goldstein <ly...@gmail.com>
Authored: Tue Mar 1 06:06:12 2016 +0200
Committer: Lyor Goldstein <ly...@gmail.com>
Committed: Tue Mar 1 06:06:12 2016 +0200

----------------------------------------------------------------------
 sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/a151b7e6/sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java b/sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java
index 292085e..1d5fd4f 100644
--- a/sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java
@@ -944,10 +944,10 @@ public class ServerTest extends BaseTestSupport {
         });
         client.start();
 
-        try (ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, sshd.getPort()).verify(777L, TimeUnit.SECONDS).getSession()) {
+        try (ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, sshd.getPort()).verify(7L, TimeUnit.SECONDS).getSession()) {
             session.addPasswordIdentity(getCurrentTestName());
-            session.auth().verify(999L, TimeUnit.SECONDS);
-            assertTrue("No signal received in time", signal.tryAcquire(1111L, TimeUnit.SECONDS));
+            session.auth().verify(9L, TimeUnit.SECONDS);
+            assertTrue("No signal received in time", signal.tryAcquire(11L, TimeUnit.SECONDS));
         } finally {
             client.stop();
         }