[ 
https://issues.apache.org/jira/browse/SSHD-634?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15129814#comment-15129814
 ] 

Goldstein Lyor commented on SSHD-634:
-------------------------------------

In _AbstractSession#decode()_ method locate the following lines:
{code:java}
inPacketsCount.incrementAndGet();
inBytesCount.addAndGet(buf.available());
// Process decoded packet
handleMessage(buf);
{code}
replace them with
{code:java}
inPacketsCount.incrementAndGet();
inBytesCount.addAndGet(buf.available());
// clone the packet to avoid buffer re-use issues
int msgLen = buf.available();
byte[] msgData = new byte[msgLen];
System.arrayCopy(buf.array(), buf.rpos(), msgData, 0, msgLen);
Buffer messageBuffer = new ByteArrayBuffer(msgData, true);
// Process decoded packet
handleMessage(messageBuffer);
{code}
This might not eliminate the problem 100% (I am still reviewing the code), but 
will make it highly unlikely.

> Suspicious read buffer re-use in write command
> ----------------------------------------------
>
>                 Key: SSHD-634
>                 URL: https://issues.apache.org/jira/browse/SSHD-634
>             Project: MINA SSHD
>          Issue Type: Bug
>    Affects Versions: 1.0.0
>            Reporter: Eugene Petrenko
>            Assignee: Goldstein Lyor
>             Fix For: 1.2.0
>
>
> From time to time I saw a {{Bad packet length ###}} errors from SSH clients 
> that calls commands to the SSHD server running with Apache SSHD. 
> It may turn out there are some issues in the implementation. 
> I found one suspicious usage of buffers around 
> {{org.apache.sshd.common.channel.AbstractChannel#sendResponse}} method. As 
> far as I see from the code it uses the read buffer as a place to generate a 
> write packet command. Maybe it's worth to create a fresh buffer here to avoid 
> it be updated from the other thread while it is put to a write queue



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to