Skip to content

Commit

Permalink
Merge pull request #3 from gaoxingliang/fixcisco
Browse files Browse the repository at this point in the history
fix #1: some cisco devices is not supported
  • Loading branch information
gaoxingliang authored Oct 30, 2018
2 parents 20c85a8 + d1f7481 commit 9a6319c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<packaging>jar</packaging>
<version>0.1.54</version>
<version>1.1.54</version>
<name>JSch</name>
<url>http://www.jcraft.com/jsch/</url>
<description>JSch is a pure Java implementation of SSH2</description>
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/com/jcraft/jsch/Channel.java
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,11 @@ private synchronized void init() throws java.io.IOException {
packet = new Packet(buffer);

byte[] _buf = buffer.buffer;
if (_buf.length - (14 + 0) - Session.buffer_margin <= 0) {
int margin = Session.buffer_margin_cisco;
if (_buf.length - (14 + 0) - margin <= 0) {
buffer = null;
packet = null;
throw new IOException("failed to initialize the channel.");
throw new IOException(String.format("failed to initialize the channel (remote maximum packet size %d, margin %d) ", rmpsize, margin));
}

}
Expand All @@ -279,8 +280,8 @@ public void write(byte[] buf, int s, int l) throws java.io.IOException {
int _bufl = _buf.length;
while (l > 0) {
int _l = l;
if (l > _bufl - (14 + dataLen) - Session.buffer_margin) {
_l = _bufl - (14 + dataLen) - Session.buffer_margin;
if (l > _bufl - (14 + dataLen) - Session.buffer_margin_cisco) {
_l = _bufl - (14 + dataLen) - Session.buffer_margin_cisco;
}

if (_l <= 0) {
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/jcraft/jsch/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ public class Session implements Runnable {
64 + // maximum mac length
32; // margin for deflater; deflater may inflate data

// in some cisco devices, the buffer is not so large
static final int buffer_margin_cisco = 32 + // maximum padding length
20 + // maximum mac length
32; // margin for deflater; deflater may inflate data


private java.util.Hashtable config = null;

private Proxy proxy = null;
Expand Down

0 comments on commit 9a6319c

Please sign in to comment.