You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by gn...@apache.org on 2020/04/22 08:32:32 UTC
[mina-sshd] branch master updated: [SSHD-979] Fix issue where the
buffer should not be modified after being submitted to writePacket
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git
The following commit(s) were added to refs/heads/master by this push:
new cc0d1c6 [SSHD-979] Fix issue where the buffer should not be modified after being submitted to writePacket
cc0d1c6 is described below
commit cc0d1c6cbd562a485b383a4c3f9ef4ecd82ebb7c
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Wed Apr 22 10:20:06 2020 +0200
[SSHD-979] Fix issue where the buffer should not be modified after being submitted to writePacket
---
.../java/org/apache/sshd/common/session/helpers/AbstractSession.java | 1 -
.../org/apache/sshd/client/subsystem/sftp/impl/DefaultSftpClient.java | 4 +++-
2 files changed, 3 insertions(+), 2 deletions(-)
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 e8eda37..47a56b9 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
@@ -955,7 +955,6 @@ public abstract class AbstractSession extends SessionHelper {
Buffer packet = resolveOutputPacket(buffer);
IoSession networkSession = getIoSession();
IoWriteFuture future = networkSession.writePacket(packet);
- buffer.rpos(buffer.wpos());
return future;
}
}
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/impl/DefaultSftpClient.java b/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/impl/DefaultSftpClient.java
index 5ef0e18..2c13f5b 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/impl/DefaultSftpClient.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/impl/DefaultSftpClient.java
@@ -529,7 +529,9 @@ public class DefaultSftpClient extends AbstractSftpClient {
buffer.putInt(channel.getRecipient());
buffer.putInt(length);
buffer.wpos(wpos);
- return buffer;
+ Buffer buf = new ByteArrayBuffer(buffer.array(), buffer.rpos(), buffer.available());
+ buffer.rpos(buffer.wpos());
+ return buf;
} else {
return super.createSendBuffer(buffer, channel, length);
}