[jcifs] Filter Bug: Transport Port 0 Incorrectly Interpreted
Michael B Allen
mba2000 at ioplex.com
Mon Sep 26 16:07:27 GMT 2005
On Mon, 26 Sep 2005 14:23:41 +0200
Oliver Schoett <os at sdm.de> wrote:
> From reading the code (guided by the line numbers in the exception
> stack above), it appears to me that the SmbTransport is created in
> SmbSession.java, line 72 (just before the call to connect in line 74)
> with destination port 0, and the local port is also 0 by default. Hence
> I think that the Socket constructor is called with both port numbers 0,
> and I find it justified for the IBM JDK 1.4.1 to throw an exception in
> this case, as these port numbers do not appear to be good for connecting
> from or to.
>
> How is this code supposed to work? Should not the destination port
> number be 139?
Port 445 but then fallback to 139 but yes, there is a bug here. Apparently
the port is normally supplied but in the case of SmbSession.logon and one
other place 0 can be specified which is incorrectly interpreted by the new
Transport code. Note that I think the faulty code will still work if you
can connect to port 139 because the exception will cause the transport
to fallback to that.
In any case, I think the fix is to add two lines to SmbTransport.java:232:
222 private void negotiate( int port, ServerMessageBlock resp ) throws IOException {
223 /* We cannot use Transport.sendrecv() yet because
224 * the Transport thread is not setup until doConnect()
225 * returns and we want to supress all communication
226 * until we have properly negotiated.
227 */
228 synchronized (sbuf) {
229 if (port == 139) {
230 ssn139();
231 } else {
232 if (port == 0)
233 port = DEFAULT_PORT; // 445
234 if (localAddr == null) {
235 socket = new Socket( address.getHostAddress(), port );
Nice catch and diagnosis. This will be added to The List.
Thanks,
Mike
More information about the jcifs
mailing list