[jira] [Created] (NET-474) Problem, in __getReply method, parsing reply code with leading space

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Created] (NET-474) Problem, in __getReply method, parsing reply code with leading space

Richard (Jira)
Ahmad created NET-474:
-------------------------

             Summary: Problem, in __getReply method, parsing reply code with leading space
                 Key: NET-474
                 URL: https://issues.apache.org/jira/browse/NET-474
             Project: Commons Net
          Issue Type: Bug
          Components: FTP
    Affects Versions: 3.1
         Environment: UNIX
            Reporter: Ahmad
             Fix For: 3.2


FTPClient.getStatus() function call failed complaining about malformed response code.

After tracing the code, I found the problem at following class and line:
*org.apache.commons.net.ftp.FTP.__getReply(FTP.java:333)*

The issue is that this method always expects reply code at position 0 of the returned reply string. If the reply string has some leading spaces, it fails to parse the reply code and returns malformed reply string.

Example of such a reply string:

{code}
      211-nhpssltest Ipswitch FTP Server
      Version 5.0.2
      Connected to 184.70.132.130
      Logged in as massba
      TYPE: ASCII, FORM: Nonprint; STRUcture: File; transfer MODE: STREAM
      No data connection
211 End of status
{code}


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Updated] (NET-474) Problem, in __getReply method, parsing reply code with leading space

Richard (Jira)

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

Sebb updated NET-474:
---------------------

    Description:
FTPClient.getStatus() function call failed complaining about malformed response code.

After tracing the code, I found the problem at following class and line:
*org.apache.commons.net.ftp.FTP.__getReply(FTP.java:333)*

The issue is that this method always expects reply code at position 0 of the returned reply string. If the reply string has some leading spaces, it fails to parse the reply code and returns malformed reply string.

Example of such a reply string:

{noformat}
      211-nhpssltest Ipswitch FTP Server
      Version 5.0.2
      Connected to 184.70.132.130
      Logged in as massba
      TYPE: ASCII, FORM: Nonprint; STRUcture: File; transfer MODE: STREAM
      No data connection
211 End of status
{noformat}


  was:
FTPClient.getStatus() function call failed complaining about malformed response code.

After tracing the code, I found the problem at following class and line:
*org.apache.commons.net.ftp.FTP.__getReply(FTP.java:333)*

The issue is that this method always expects reply code at position 0 of the returned reply string. If the reply string has some leading spaces, it fails to parse the reply code and returns malformed reply string.

Example of such a reply string:

{code}
      211-nhpssltest Ipswitch FTP Server
      Version 5.0.2
      Connected to 184.70.132.130
      Logged in as massba
      TYPE: ASCII, FORM: Nonprint; STRUcture: File; transfer MODE: STREAM
      No data connection
211 End of status
{code}



Use "noformat" instead of "code" because the latter truncates leading spaces.
[Ironic, here!]
               

> Problem, in __getReply method, parsing reply code with leading space
> --------------------------------------------------------------------
>
>                 Key: NET-474
>                 URL: https://issues.apache.org/jira/browse/NET-474
>             Project: Commons Net
>          Issue Type: Bug
>          Components: FTP
>    Affects Versions: 3.1
>         Environment: UNIX
>            Reporter: Ahmad AMIN
>             Fix For: 3.2
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> FTPClient.getStatus() function call failed complaining about malformed response code.
> After tracing the code, I found the problem at following class and line:
> *org.apache.commons.net.ftp.FTP.__getReply(FTP.java:333)*
> The issue is that this method always expects reply code at position 0 of the returned reply string. If the reply string has some leading spaces, it fails to parse the reply code and returns malformed reply string.
> Example of such a reply string:
> {noformat}
>       211-nhpssltest Ipswitch FTP Server
>       Version 5.0.2
>       Connected to 184.70.132.130
>       Logged in as massba
>       TYPE: ASCII, FORM: Nonprint; STRUcture: File; transfer MODE: STREAM
>       No data connection
> 211 End of status
> {noformat}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (NET-474) Problem, in __getReply method, parsing reply code with leading space

Richard (Jira)
In reply to this post by Richard (Jira)

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

Sebb commented on NET-474:
--------------------------

As far as I can tell, the RFCs don't permit leading spaces before the reply code, so the server you are using is broken.

AFAIK this is the only report of such behaviour.

I don't think NET should be changed to cater for a broken server implementation.
               

> Problem, in __getReply method, parsing reply code with leading space
> --------------------------------------------------------------------
>
>                 Key: NET-474
>                 URL: https://issues.apache.org/jira/browse/NET-474
>             Project: Commons Net
>          Issue Type: Bug
>          Components: FTP
>    Affects Versions: 3.1
>         Environment: UNIX
>            Reporter: Ahmad AMIN
>             Fix For: 3.2
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> FTPClient.getStatus() function call failed complaining about malformed response code.
> After tracing the code, I found the problem at following class and line:
> *org.apache.commons.net.ftp.FTP.__getReply(FTP.java:333)*
> The issue is that this method always expects reply code at position 0 of the returned reply string. If the reply string has some leading spaces, it fails to parse the reply code and returns malformed reply string.
> Example of such a reply string:
> {noformat}
>       211-nhpssltest Ipswitch FTP Server
>       Version 5.0.2
>       Connected to 184.70.132.130
>       Logged in as massba
>       TYPE: ASCII, FORM: Nonprint; STRUcture: File; transfer MODE: STREAM
>       No data connection
> 211 End of status
> {noformat}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (NET-474) Problem, in __getReply method, parsing reply code with leading space

Richard (Jira)
In reply to this post by Richard (Jira)

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

Ahmad AMIN commented on NET-474:
--------------------------------

Anyways, I think this is a silly bug which can be fixed pretty easily. Besides, the server belongs to a government agency, I can't tell them to retire it just like that.
               

> Problem, in __getReply method, parsing reply code with leading space
> --------------------------------------------------------------------
>
>                 Key: NET-474
>                 URL: https://issues.apache.org/jira/browse/NET-474
>             Project: Commons Net
>          Issue Type: Bug
>          Components: FTP
>    Affects Versions: 3.1
>         Environment: UNIX
>            Reporter: Ahmad AMIN
>             Fix For: 3.2
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> FTPClient.getStatus() function call failed complaining about malformed response code.
> After tracing the code, I found the problem at following class and line:
> *org.apache.commons.net.ftp.FTP.__getReply(FTP.java:333)*
> The issue is that this method always expects reply code at position 0 of the returned reply string. If the reply string has some leading spaces, it fails to parse the reply code and returns malformed reply string.
> Example of such a reply string:
> {noformat}
>       211-nhpssltest Ipswitch FTP Server
>       Version 5.0.2
>       Connected to 184.70.132.130
>       Logged in as massba
>       TYPE: ASCII, FORM: Nonprint; STRUcture: File; transfer MODE: STREAM
>       No data connection
> 211 End of status
> {noformat}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (NET-474) Problem, in __getReply method, parsing reply code with leading space

Richard (Jira)
In reply to this post by Richard (Jira)

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

Sebb commented on NET-474:
--------------------------

Sorry, but unless you can point to documentation that says that leading spaces are allowed by the FTP protocol, then the bug is in the server, not Commons NET.

I suggest advising them that the server appears to be faulty so they can contact their supplier to get it fixed.

[By the way, a net search suggests that version 5.0.2 is quite old, and may have some security issues, so it might be as well to upgrade anyway. That might well fix the reply format too.]
               

> Problem, in __getReply method, parsing reply code with leading space
> --------------------------------------------------------------------
>
>                 Key: NET-474
>                 URL: https://issues.apache.org/jira/browse/NET-474
>             Project: Commons Net
>          Issue Type: Bug
>          Components: FTP
>    Affects Versions: 3.1
>         Environment: UNIX
>            Reporter: Ahmad AMIN
>             Fix For: 3.2
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> FTPClient.getStatus() function call failed complaining about malformed response code.
> After tracing the code, I found the problem at following class and line:
> *org.apache.commons.net.ftp.FTP.__getReply(FTP.java:333)*
> The issue is that this method always expects reply code at position 0 of the returned reply string. If the reply string has some leading spaces, it fails to parse the reply code and returns malformed reply string.
> Example of such a reply string:
> {noformat}
>       211-nhpssltest Ipswitch FTP Server
>       Version 5.0.2
>       Connected to 184.70.132.130
>       Logged in as massba
>       TYPE: ASCII, FORM: Nonprint; STRUcture: File; transfer MODE: STREAM
>       No data connection
> 211 End of status
> {noformat}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Resolved] (NET-474) Problem, in __getReply method, parsing reply code with leading space

Richard (Jira)
In reply to this post by Richard (Jira)

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

Sebb resolved NET-474.
----------------------

    Resolution: Won't Fix
   

> Problem, in __getReply method, parsing reply code with leading space
> --------------------------------------------------------------------
>
>                 Key: NET-474
>                 URL: https://issues.apache.org/jira/browse/NET-474
>             Project: Commons Net
>          Issue Type: Bug
>          Components: FTP
>    Affects Versions: 3.1
>         Environment: UNIX
>            Reporter: Ahmad AMIN
>             Fix For: 3.2
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> FTPClient.getStatus() function call failed complaining about malformed response code.
> After tracing the code, I found the problem at following class and line:
> *org.apache.commons.net.ftp.FTP.__getReply(FTP.java:333)*
> The issue is that this method always expects reply code at position 0 of the returned reply string. If the reply string has some leading spaces, it fails to parse the reply code and returns malformed reply string.
> Example of such a reply string:
> {noformat}
>       211-nhpssltest Ipswitch FTP Server
>       Version 5.0.2
>       Connected to 184.70.132.130
>       Logged in as massba
>       TYPE: ASCII, FORM: Nonprint; STRUcture: File; transfer MODE: STREAM
>       No data connection
> 211 End of status
> {noformat}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (NET-474) Problem, in __getReply method, parsing reply code with leading space

Richard (Jira)
In reply to this post by Richard (Jira)

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

Gary D. Gregory commented on NET-474:
-------------------------------------

Is it worth discussing adding a lenient vs. strict setting to the FTP class to allow for such misbehaved servers? The strict mode is as it is now. Lenient would trim to reply line before attempting to parse it.

If not, what about changing __getReply to protected to allow for overriding?
               

> Problem, in __getReply method, parsing reply code with leading space
> --------------------------------------------------------------------
>
>                 Key: NET-474
>                 URL: https://issues.apache.org/jira/browse/NET-474
>             Project: Commons Net
>          Issue Type: Bug
>          Components: FTP
>    Affects Versions: 3.1
>         Environment: UNIX
>            Reporter: Ahmad AMIN
>             Fix For: 3.2
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> FTPClient.getStatus() function call failed complaining about malformed response code.
> After tracing the code, I found the problem at following class and line:
> *org.apache.commons.net.ftp.FTP.__getReply(FTP.java:333)*
> The issue is that this method always expects reply code at position 0 of the returned reply string. If the reply string has some leading spaces, it fails to parse the reply code and returns malformed reply string.
> Example of such a reply string:
> {noformat}
>       211-nhpssltest Ipswitch FTP Server
>       Version 5.0.2
>       Connected to 184.70.132.130
>       Logged in as massba
>       TYPE: ASCII, FORM: Nonprint; STRUcture: File; transfer MODE: STREAM
>       No data connection
> 211 End of status
> {noformat}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (NET-474) Problem, in __getReply method, parsing reply code with leading space

Richard (Jira)
In reply to this post by Richard (Jira)

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

Sebb commented on NET-474:
--------------------------

This is the first and only report of a server that apparently sends leading spaces.
IMO adding lenient processing is overkill/unnecessary feature creep.

If it really is a genuine problem affecting more than 1 specific server version then it might be worth allowing __getReply to be overridden, as that is probably the easiest solution.
               

> Problem, in __getReply method, parsing reply code with leading space
> --------------------------------------------------------------------
>
>                 Key: NET-474
>                 URL: https://issues.apache.org/jira/browse/NET-474
>             Project: Commons Net
>          Issue Type: Bug
>          Components: FTP
>    Affects Versions: 3.1
>         Environment: UNIX
>            Reporter: Ahmad AMIN
>             Fix For: 3.2
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> FTPClient.getStatus() function call failed complaining about malformed response code.
> After tracing the code, I found the problem at following class and line:
> *org.apache.commons.net.ftp.FTP.__getReply(FTP.java:333)*
> The issue is that this method always expects reply code at position 0 of the returned reply string. If the reply string has some leading spaces, it fails to parse the reply code and returns malformed reply string.
> Example of such a reply string:
> {noformat}
>       211-nhpssltest Ipswitch FTP Server
>       Version 5.0.2
>       Connected to 184.70.132.130
>       Logged in as massba
>       TYPE: ASCII, FORM: Nonprint; STRUcture: File; transfer MODE: STREAM
>       No data connection
> 211 End of status
> {noformat}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (NET-474) Problem, in __getReply method, parsing reply code with leading space

Richard (Jira)
In reply to this post by Richard (Jira)

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

Sebb commented on NET-474:
--------------------------

Here is a sample session to a recent version of the server:

{noformat}
Connected to ftp.ipswitch.com.
220 ftp6.ipswitch.com X2 WS_FTP Server 7.5.1(76307814)
331 Enter password
230 User logged in
Remote system type is UNIX.
ftp> quote stat
211-System status Ipswitch FTP Server
 Version WS_FTP Server 7.5.1
 Connected to 192.168.100.130
 Logged in as anonymous
 TYPE: BINARY, FORM: Nonprint; STRUcture: File; transfer MODE: STREAM
 No data connection
211 End of status
ftp> bye
221 bye
{noformat}

Note that the reply codes start in column 1 (index 0).
               

> Problem, in __getReply method, parsing reply code with leading space
> --------------------------------------------------------------------
>
>                 Key: NET-474
>                 URL: https://issues.apache.org/jira/browse/NET-474
>             Project: Commons Net
>          Issue Type: Bug
>          Components: FTP
>    Affects Versions: 3.1
>         Environment: UNIX
>            Reporter: Ahmad AMIN
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> FTPClient.getStatus() function call failed complaining about malformed response code.
> After tracing the code, I found the problem at following class and line:
> *org.apache.commons.net.ftp.FTP.__getReply(FTP.java:333)*
> The issue is that this method always expects reply code at position 0 of the returned reply string. If the reply string has some leading spaces, it fails to parse the reply code and returns malformed reply string.
> Example of such a reply string:
> {noformat}
>       211-nhpssltest Ipswitch FTP Server
>       Version 5.0.2
>       Connected to 184.70.132.130
>       Logged in as massba
>       TYPE: ASCII, FORM: Nonprint; STRUcture: File; transfer MODE: STREAM
>       No data connection
> 211 End of status
> {noformat}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Updated] (NET-474) Problem, in __getReply method, parsing reply code with leading space

Richard (Jira)
In reply to this post by Richard (Jira)

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

Sebb updated NET-474:
---------------------

    Fix Version/s:     (was: 3.2)
   

> Problem, in __getReply method, parsing reply code with leading space
> --------------------------------------------------------------------
>
>                 Key: NET-474
>                 URL: https://issues.apache.org/jira/browse/NET-474
>             Project: Commons Net
>          Issue Type: Bug
>          Components: FTP
>    Affects Versions: 3.1
>         Environment: UNIX
>            Reporter: Ahmad AMIN
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> FTPClient.getStatus() function call failed complaining about malformed response code.
> After tracing the code, I found the problem at following class and line:
> *org.apache.commons.net.ftp.FTP.__getReply(FTP.java:333)*
> The issue is that this method always expects reply code at position 0 of the returned reply string. If the reply string has some leading spaces, it fails to parse the reply code and returns malformed reply string.
> Example of such a reply string:
> {noformat}
>       211-nhpssltest Ipswitch FTP Server
>       Version 5.0.2
>       Connected to 184.70.132.130
>       Logged in as massba
>       TYPE: ASCII, FORM: Nonprint; STRUcture: File; transfer MODE: STREAM
>       No data connection
> 211 End of status
> {noformat}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Closed] (NET-474) Problem, in __getReply method, parsing reply code with leading space

Richard (Jira)
In reply to this post by Richard (Jira)

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

Sebb closed NET-474.
--------------------

   

> Problem, in __getReply method, parsing reply code with leading space
> --------------------------------------------------------------------
>
>                 Key: NET-474
>                 URL: https://issues.apache.org/jira/browse/NET-474
>             Project: Commons Net
>          Issue Type: Bug
>          Components: FTP
>    Affects Versions: 3.1
>         Environment: UNIX
>            Reporter: Ahmad AMIN
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> FTPClient.getStatus() function call failed complaining about malformed response code.
> After tracing the code, I found the problem at following class and line:
> *org.apache.commons.net.ftp.FTP.__getReply(FTP.java:333)*
> The issue is that this method always expects reply code at position 0 of the returned reply string. If the reply string has some leading spaces, it fails to parse the reply code and returns malformed reply string.
> Example of such a reply string:
> {noformat}
>       211-nhpssltest Ipswitch FTP Server
>       Version 5.0.2
>       Connected to 184.70.132.130
>       Logged in as massba
>       TYPE: ASCII, FORM: Nonprint; STRUcture: File; transfer MODE: STREAM
>       No data connection
> 211 End of status
> {noformat}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira