[jira] [Updated] (SSHD-1182) skip() doesn't work properly in SftpInputStreamAsync

2021-06-14 Thread Pavel Stetsuk (Jira)


 [ 
https://issues.apache.org/jira/browse/SSHD-1182?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Pavel Stetsuk updated SSHD-1182:

Description: 
skip() doesn't work properly in SftpInputStreamAsync if executed before read a 
data.

In this case data read from the beginning and skip() is ignored

  was:skip() doesn't work properly in SftpInputStreamAsync if executed before 
read a data


> skip() doesn't work properly in SftpInputStreamAsync
> 
>
> Key: SSHD-1182
> URL: https://issues.apache.org/jira/browse/SSHD-1182
> Project: MINA SSHD
>  Issue Type: Bug
>Reporter: Pavel Stetsuk
>Priority: Major
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> skip() doesn't work properly in SftpInputStreamAsync if executed before read 
> a data.
> In this case data read from the beginning and skip() is ignored



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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



[jira] [Work logged] (SSHD-1182) skip() doesn't work properly in SftpInputStreamAsync

2021-06-14 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/SSHD-1182?focusedWorklogId=611160&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-611160
 ]

ASF GitHub Bot logged work on SSHD-1182:


Author: ASF GitHub Bot
Created on: 15/Jun/21 06:38
Start Date: 15/Jun/21 06:38
Worklog Time Spent: 10m 
  Work Description: pstetsuk opened a new pull request #200:
URL: https://github.com/apache/mina-sshd/pull/200


   modified `SftpTest.testInputStreamSkipAndReset()` to reproduce this issue


-- 
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:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 611160)
Remaining Estimate: 0h
Time Spent: 10m

> skip() doesn't work properly in SftpInputStreamAsync
> 
>
> Key: SSHD-1182
> URL: https://issues.apache.org/jira/browse/SSHD-1182
> Project: MINA SSHD
>  Issue Type: Bug
>Reporter: Pavel Stetsuk
>Priority: Major
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> skip() doesn't work properly in SftpInputStreamAsync if executed before read 
> a data



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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



[GitHub] [mina-sshd] pstetsuk opened a new pull request #200: [SSHD-1182] skip() doesn't work properly in SftpInputStreamAsync

2021-06-14 Thread GitBox


pstetsuk opened a new pull request #200:
URL: https://github.com/apache/mina-sshd/pull/200


   modified `SftpTest.testInputStreamSkipAndReset()` to reproduce this issue


-- 
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:
us...@infra.apache.org



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



[jira] [Created] (SSHD-1182) skip() doesn't work properly in SftpInputStreamAsync

2021-06-14 Thread Pavel Stetsuk (Jira)
Pavel Stetsuk created SSHD-1182:
---

 Summary: skip() doesn't work properly in SftpInputStreamAsync
 Key: SSHD-1182
 URL: https://issues.apache.org/jira/browse/SSHD-1182
 Project: MINA SSHD
  Issue Type: Bug
Reporter: Pavel Stetsuk


skip() doesn't work properly in SftpInputStreamAsync if executed before read a 
data



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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



[GitHub] [mina-sshd] gnodet merged pull request #199: Sshd 1181

2021-06-14 Thread GitBox


gnodet merged pull request #199:
URL: https://github.com/apache/mina-sshd/pull/199


   


-- 
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:
us...@infra.apache.org



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



[GitHub] [mina-sshd] gnodet opened a new pull request #199: Sshd 1181

2021-06-14 Thread GitBox


gnodet opened a new pull request #199:
URL: https://github.com/apache/mina-sshd/pull/199


   


-- 
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:
us...@infra.apache.org



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



[GitHub] [mina-sshd] gnodet commented on pull request #199: Sshd 1181

2021-06-14 Thread GitBox


gnodet commented on pull request #199:
URL: https://github.com/apache/mina-sshd/pull/199#issuecomment-859611076


   I think the number of requests sent for downloading small files is not 
really optimal. This could be improved.


-- 
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:
us...@infra.apache.org



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



[jira] [Resolved] (SSHD-1178) SOCKS5 proxy stand-alone code

2021-06-14 Thread Guillaume Nodet (Jira)


 [ 
https://issues.apache.org/jira/browse/SSHD-1178?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Guillaume Nodet resolved SSHD-1178.
---
Resolution: Not A Problem

Maybe you could start by reading the doc: 
https://github.com/apache/mina-sshd/blob/master/docs/port-forwarding.md

> SOCKS5 proxy stand-alone code
> -
>
> Key: SSHD-1178
> URL: https://issues.apache.org/jira/browse/SSHD-1178
> Project: MINA SSHD
>  Issue Type: Question
>Reporter: Susmit Sarkar
>Priority: Blocker
>
> Hello Team,
> I want to create a SOCKS5 server using MINA sshd. I am not getting sure from 
> where to start. Shall be really grateful if someone can help with an example 
> code for standalone proxy server using mina sshd
> Are SOCKS5 proxy and SSH Jumps both same?
>  
> Thanks,
> Susmit



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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



[jira] [Resolved] (SSHD-1181) SFTP Get downloads empty file from servers which supports EOF indication after data

2021-06-14 Thread Guillaume Nodet (Jira)


 [ 
https://issues.apache.org/jira/browse/SSHD-1181?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Guillaume Nodet resolved SSHD-1181.
---
Fix Version/s: 2.7.1
   Resolution: Fixed

https://github.com/apache/mina-sshd/commit/3db721d9a109d9aa80b3a662c43b57458acd99e4

> SFTP Get downloads empty file from servers which supports EOF indication 
> after data
> ---
>
> Key: SSHD-1181
> URL: https://issues.apache.org/jira/browse/SSHD-1181
> Project: MINA SSHD
>  Issue Type: Bug
>Affects Versions: 2.6.0
>Reporter: Pavel Pohner
>Assignee: Guillaume Nodet
>Priority: Major
>  Labels: SFTP, mina, sshd
> Fix For: 2.7.1
>
>
> So, apparently there's a bug in Mina implementation when downloading the 
> file, which is smaller than Mina's buffer (meaning it gets read in one 
> iteration), from servers, which send EOF indicator at the end of data 
> (https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-13#[section-9.3|https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-13#section-9.3]).
> The bug seems to be in setting up EOF indicator in 
> {noformat}
> org.apache.sshd.sftp.client.impl.SftpInputStreamAsync#pollBuffer{noformat}
> prematurely (one iteration sooner), trace with me this example situation - 
> download of the small file (14 B):
> At some point we arrive to mentioned function _pollBuffer()_, note that 
> _this.pendingReads_ is set to 2. In first call of _pollBuffer()_ we go 
> through this code on receiving SSH_FXP_DATA
> {code:java}
> if (type == SftpConstants.SSH_FXP_DATA) {
> int dlen = buf.getInt();
> int rpos = buf.rpos();
> buf.rpos(rpos + dlen);
> Boolean b = SftpHelper.getEndOfFileIndicatorValue(buf, 
> client.getVersion());
> if ((b != null) && b.booleanValue()) {
> eofIndicator = true;
> }{code}
> Here, consider this situation, we're downloading file with 14B, remote server 
> adds EOF indicator to the end of the data, so it makes 15B, let's add some 
> necessary overhead (size etc.) which is, according to my experience, 13B, so 
> we receive 15 + 13 = 28B into initial buffer.
> Now, if we populate these variables, _dlen_ = 14B (file size), _rpos_ = 13 
> (overhead), and we set _buf.rpos_ to 27 (14 + 13), but _wpos_ is at the 
> moment equal to 28B, as that's what we received. (We're not taking EOF into 
> account here)
> Then the _SftpHelper.getEndOfFileIndicatorValue_ is called, which in it's 
> implementation looks like this:
> {code:java}
> public static Boolean getEndOfFileIndicatorValue(Buffer buffer, int version) {
> return (version < SftpConstants.SFTP_V6) || (buffer.available() < 1) ? 
> null : buffer.getBoolean();
> }
> {code}
> Pay attention to the _buffer.available()_ function as it's implemented like 
> this:
> {code:java}
> public int available() {
> return wpos - rpos;
> }
> {code}
> therefore returning 1 (28 - 27), condition is then resolved in 
> _SftpHelper.getEndOfFileIndicatorValue_ as a true and true is also returned 
> to the _pollBuffer_ and _eofIndicator_ is set to true.
> If you'd keep tracing further, you'd find out that the buffer is then never 
> read and returned from _SftpInputStreamAsync_ class, just because 
> _eofIndicator_ was set sooner than it should have been.
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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