You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Przemek Bruski (JIRA)" <ji...@apache.org> on 2014/07/08 23:08:04 UTC

[jira] [Commented] (SSHD-333) Ephemeral port handling is faulty

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

Przemek Bruski commented on SSHD-333:
-------------------------------------

There's a race condition in the implemented solution.

> Ephemeral port handling is faulty
> ---------------------------------
>
>                 Key: SSHD-333
>                 URL: https://issues.apache.org/jira/browse/SSHD-333
>             Project: MINA SSHD
>          Issue Type: Bug
>    Affects Versions: 0.9.0
>            Reporter: Przemek Bruski
>            Assignee: Guillaume Nodet
>             Fix For: 0.12.0
>
>
> An excerpt from org.apache.sshd.SshServer:
> {code}
>       if (host != null) {
>             String[] hosts = host.split(",");
>             LinkedList<InetSocketAddress> addresses = new LinkedList<InetSocketAddress>();
>             for (String host : hosts) {
>                 InetAddress[] inetAddresses = InetAddress.getAllByName(host);
>                 for (InetAddress inetAddress : inetAddresses) {
>                     InetSocketAddress inetSocketAddress = new InetSocketAddress(inetAddress, port);
>                     if (port == 0) {
>                         port = inetSocketAddress.getPort();
>                     }
>                     addresses.add(inetSocketAddress);
>                 }
>             }
>             acceptor.bind(addresses);
>         }
> {code}
> The line:
> {code}
>                     if (port == 0) {
>                         port = inetSocketAddress.getPort();
>                     }
> {code}
> Will still retrieve 0. The ephemeral port can be determined only after the socket address is bound.



--
This message was sent by Atlassian JIRA
(v6.2#6252)