You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by GitBox <gi...@apache.org> on 2020/02/21 10:56:50 UTC

[GitHub] [mina-sshd] lgoldstein commented on a change in pull request #111: [SSHD-967] fixed byte buffer issue

lgoldstein commented on a change in pull request #111: [SSHD-967] fixed byte buffer issue
URL: https://github.com/apache/mina-sshd/pull/111#discussion_r382520189
 
 

 ##########
 File path: sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpRemotePathChannel.java
 ##########
 @@ -262,7 +262,7 @@ public long transferTo(long position, long count, WritableByteChannel target) th
                 while (totalRead < count) {
                     int read = sftp.read(handle, curPos, buffer, 0, buffer.length);
                     if (read > 0) {
-                        ByteBuffer wrap = ByteBuffer.wrap(buffer);
+                        ByteBuffer wrap = ByteBuffer.wrap(buffer, 0,  (int) Math.min(count - totalRead, buffer.length));
 
 Review comment:
   Shouldn't this be ?
   
   ```java
   ByteBuffer wrap = ByteBuffer.wrap(buffer, 0,  read);
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org