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:12:48 UTC

[2/2] mina-sshd git commit: Add null char test of AbstractSession#doReadIdentification

Add null char test of AbstractSession#doReadIdentification


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

Branch: refs/heads/master
Commit: 05f3c8f2d5c40cefe39bd99f3bcebdca63fb9a07
Parents: ca56309
Author: Lyor Goldstein <ly...@gmail.com>
Authored: Tue Mar 1 06:13:38 2016 +0200
Committer: Lyor Goldstein <ly...@gmail.com>
Committed: Tue Mar 1 06:13:38 2016 +0200

----------------------------------------------------------------------
 .../sshd/common/session/helpers/AbstractSessionTest.java    | 9 +++++++++
 1 file changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/05f3c8f2/sshd-core/src/test/java/org/apache/sshd/common/session/helpers/AbstractSessionTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/session/helpers/AbstractSessionTest.java b/sshd-core/src/test/java/org/apache/sshd/common/session/helpers/AbstractSessionTest.java
index fbf3d3a..41622ca 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/session/helpers/AbstractSessionTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/session/helpers/AbstractSessionTest.java
@@ -126,6 +126,15 @@ public class AbstractSessionTest extends BaseTestSupport {
     }
 
     @Test(expected = IllegalStateException.class)
+    public void testReadIdentWithNullChar() {
+        StringBuilder sb = new StringBuilder(Session.MAX_VERSION_LINE_LENGTH + Integer.SIZE);
+        sb.append("SSH-2.0").append('\0').append("-software\r\n");
+        Buffer buf = new ByteArrayBuffer(sb.toString().getBytes(StandardCharsets.UTF_8));
+        String ident = readIdentification(session, buf);
+        fail("Unexpected success: " + ident);
+    }
+
+    @Test(expected = IllegalStateException.class)
     public void testReadIdentLongHeader() {
         StringBuilder sb = new StringBuilder(FactoryManager.DEFAULT_MAX_IDENTIFICATION_SIZE + Integer.SIZE);
         do {