[
https://issues.apache.org/jira/browse/SSHD-424?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Goldstein Lyor updated SSHD-424:
--------------------------------
Attachment: 0027-SSHD-424-Avoid-inadvertent-closure-of-the-input-stre.patch
Attached recommended patch
> Avoid inadvertent closure of the input stream used by ScpHelper#receiveFile
> ---------------------------------------------------------------------------
>
> Key: SSHD-424
> URL: https://issues.apache.org/jira/browse/SSHD-424
> Project: MINA SSHD
> Issue Type: Bug
> Affects Versions: 1.0.0, 0.14.0
> Reporter: Goldstein Lyor
> Priority: Minor
> Attachments:
> 0027-SSHD-424-Avoid-inadvertent-closure-of-the-input-stre.patch
>
>
> The current code wraps the session _InputStream_ inside a _FilterInputStream_
> in order to limit the available data for read to the specified length.
> However, the _FilterInputStream_ instance _close_ method is not overridden -
> i.e., if the wrapper stream is closed, this will also close the session
> stream, which would make it impossible to read the ACK (or other SCP
> commands). Granted, that the current wrapper stream is not inside a
> _try-with-resource_ block, so *theoretically* it's _close_ method should not
> be called. However, there are good reasons to (a) override the _close_ method
> and *explicitly* avoid closing the wrapped stream and (b) place the wrapped
> stream inside a _try-with-resource_ block:
> * Good programming practices - if a data stream goes out of scope, make sure
> it is closed.
> * Avoid a possible race condition between the garbage collector and our code.
> When the garbage collector decides that the wrapper stream is no longer
> required, it may also decide to close it. However, it may occur while we are
> trying to read the ACK or be in the midst of processing another SCP command.
> In such a scenario we would get an _IOException_ on an *unrelated* command.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)