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 2014/06/03 09:26:36 UTC

git commit: [SSHD-326] Fix for bug in DefaultSftpClient#write(String)

Repository: mina-sshd
Updated Branches:
  refs/heads/master 8c09eef09 -> 01a515ffb


[SSHD-326] Fix for bug in DefaultSftpClient#write(String)

Previously, DefaultSftpClient#write(String) returned an OutputStream that had a
bug in OutputStream#write(byte[],int,int): Since off was never updated, anything
copied into the buffer was from the first 32 KiB of the array passed as first
argument.

This commit also makes sure that the OutputStream returned by
DefaultSftpClient#write(String) performs a flush on close().


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

Branch: refs/heads/master
Commit: 01a515ffbb5b09caed5cbb8f8b7e637b77ef72b0
Parents: 8c09eef
Author: Florian Schoppmann <ma...@florian-schoppmann.net>
Authored: Mon Jun 2 21:35:27 2014 -0700
Committer: Guillaume Nodet <gn...@apache.org>
Committed: Tue Jun 3 08:37:37 2014 +0200

----------------------------------------------------------------------
 .../main/java/org/apache/sshd/client/sftp/DefaultSftpClient.java | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/01a515ff/sshd-core/src/main/java/org/apache/sshd/client/sftp/DefaultSftpClient.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/sftp/DefaultSftpClient.java b/sshd-core/src/main/java/org/apache/sshd/client/sftp/DefaultSftpClient.java
index abd8106..5f4420d 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/sftp/DefaultSftpClient.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/sftp/DefaultSftpClient.java
@@ -709,6 +709,7 @@ public class DefaultSftpClient implements SftpClient {
                     if (index == buffer.length) {
                         flush();
                     }
+                    off += nb;
                     len -= nb;
                 } while (len > 0);
             }
@@ -720,6 +721,9 @@ public class DefaultSftpClient implements SftpClient {
             }
             @Override
             public void close() throws IOException {
+                if (index > 0) {
+                    flush();
+                }
                 DefaultSftpClient.this.close(handle);
             }
         };