[jcifs] Wrong SMB port leads to using all free connections

Gergan Dimitrov gergan.dimitrov at gmail.com
Thu Jan 20 05:25:46 MST 2011


Hi all,

I found a problem when using port different from the default 445. If the
specified port is wrong, and the actual server accepts connections on the
default 445 port, due to this code:

try {
      negotiate( port, resp );
} catch( ConnectException ce )  {
      port = (port == 0 || port == DEFAULT_PORT) ? 139 : DEFAULT_PORT;
      negotiate( port, resp );
}

the connection is successful and the fact the port is wrong is hidden from
the user. But since the port is changed to the default, and the user is not
aware, when later other operation is performed on smb file configured with
the wrong port, the already opened session cannot be reused, since the
'matches' method on the SmbTransport class fails because of this: (port == 0
|| port == this.port). Port here is the wrong one, while this.port is
actually the default. As a result, a new SmbTransport is created. Thus, on
each file operation, a new transport is created and after a short time on
extensive operations, we get run out of free connections.

I think this silent port change is not correct - I prefer thwrowing the
exception here, so that we know there is a problem. I suggest this to be
fixed. Also, a configuration property can be added to modify this behaviour
- to throw exception or not.

Regards,
Gergan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.samba.org/pipermail/jcifs/attachments/20110120/5bb14153/attachment.html>


More information about the jCIFS mailing list