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/20 20:03:14 UTC

[GitHub] [mina-sshd] NitinRanjan opened a new pull request #111: [SSHD-967] fixed byte buffer issue

NitinRanjan opened a new pull request #111: [SSHD-967] fixed byte buffer issue
URL: https://github.com/apache/mina-sshd/pull/111
 
 
   In the last cycle of write if read size was less than buffer size remaining buffer indexes was still containing old value and was flushed in the file.
   Fix this by giving the amount of byte to be wrapped to  flushed to file

----------------------------------------------------------------
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


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

Posted by GitBox <gi...@apache.org>.
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


[GitHub] [mina-sshd] lgoldstein commented on issue #111: [SSHD-967] fixed byte buffer issue

Posted by GitBox <gi...@apache.org>.
lgoldstein commented on issue #111: [SSHD-967] fixed byte buffer issue
URL: https://github.com/apache/mina-sshd/pull/111#issuecomment-589618518
 
 
   Sorry to have misled you - after reviewing the code I thing the fix is slightly more complex than that. I am working on something myself and will post it shortly for you to review and test...

----------------------------------------------------------------
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


[GitHub] [mina-sshd] lgoldstein edited a comment on issue #111: [SSHD-967] fixed byte buffer issue

Posted by GitBox <gi...@apache.org>.
lgoldstein edited a comment on issue #111: [SSHD-967] fixed byte buffer issue
URL: https://github.com/apache/mina-sshd/pull/111#issuecomment-589618518
 
 
   Sorry to have misled you - after reviewing the code I think the fix is slightly more complex than that. I am working on something myself and will post it shortly for you to review and test...

----------------------------------------------------------------
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


[GitHub] [mina-sshd] lgoldstein commented on issue #111: [SSHD-967] fixed byte buffer issue

Posted by GitBox <gi...@apache.org>.
lgoldstein commented on issue #111: [SSHD-967] fixed byte buffer issue
URL: https://github.com/apache/mina-sshd/pull/111#issuecomment-589606253
 
 
   I would feel better if you could also add a unit test that checks specifically this issue (shouldn't be too hard). First write the unit test and make sure it fails on the **unpatched** code, then apply the patch and see that the test succeeds.

----------------------------------------------------------------
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


[GitHub] [mina-sshd] gnodet closed pull request #111: [SSHD-967] fixed byte buffer issue

Posted by GitBox <gi...@apache.org>.
gnodet closed pull request #111: [SSHD-967] fixed byte buffer issue
URL: https://github.com/apache/mina-sshd/pull/111
 
 
   

----------------------------------------------------------------
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


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

Posted by GitBox <gi...@apache.org>.
NitinRanjan commented on a change in pull request #111: [SSHD-967] fixed byte buffer issue
URL: https://github.com/apache/mina-sshd/pull/111#discussion_r382537338
 
 

 ##########
 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:
   Both are same, but to make it understand easily it is better to change it to read.
    I have tested with read and it working fine. Committed the change to forked branch

----------------------------------------------------------------
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


[GitHub] [mina-sshd] lgoldstein commented on issue #111: [SSHD-967] fixed byte buffer issue

Posted by GitBox <gi...@apache.org>.
lgoldstein commented on issue #111: [SSHD-967] fixed byte buffer issue
URL: https://github.com/apache/mina-sshd/pull/111#issuecomment-589625988
 
 
   Please clone https://github.com/lgoldstein/mina-sshd/tree/SSHD-967 compile and try

----------------------------------------------------------------
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