[jcifs] SmbException when reading file

Gherardi, Alessandro alessandro.gherardi at qwest.com
Fri Sep 10 13:49:38 GMT 2004


I'm getting the following exception when trying to read a file on a SMB
share with jcifs 1.0.1:

Exception in thread "main" jcifs.smb.SmbException: Timeout waiting for
response from server: XYZ/1.2.3.4
        at jcifs.smb.SmbTransport.send(SmbTransport.java:641)
        at jcifs.smb.SmbSession.send(SmbSession.java:154)
        at jcifs.smb.SmbTree.send(SmbTree.java:103)
        at jcifs.smb.SmbFile.send(SmbFile.java:724)
        at
jcifs.smb.SmbFileInputStream.read(SmbFileInputStream.java:144)
        at
java.io.BufferedInputStream.read1(BufferedInputStream.java:220)
        at
java.io.BufferedInputStream.read(BufferedInputStream.java:277)
        at java.io.FilterInputStream.read(FilterInputStream.java:90)
        at Test.main(Test.java:37)

The file is 8 bytes long. An Ethereal network capture shows the
following packets:

client -> server	Read AndX Request, FID: 0x003f, 2048 bytes at
offset 0
server -> client  Read AndX Response, FID: 0x003f, 8 bytes
client -> server	Read AndX Request, FID: 0x003f, 2048 bytes at
offset 8
server -> client  Read AndX Response, FID: 0x003f, 0 bytes
(15 seconds later)
client -> server	TCP/IP FIN

The last Read AndX Response has - among others - the following
parameters:

Byte Count (BCC): 1
Padding: 00
File Data: <MISSING>

I'm wondering if this problem is caused by a bug in JCIFS. Specifically,
the function that reads the file data is
SmbComReadAndXResponse::readBytesDirectWireFormat(). In 1.0.1, the
functions reads as follows:

 int readBytesDirectWireFormat( InputStream in, int byteCount, byte[]
buffer, int bufferIndex ) throws IOException {
        int pad = dataOffset - ( HEADER_LENGTH + 3 + wordCount * 2 );
        in.read( buffer, bufferIndex, pad ); /* needed for signing */
        in.read( b, off, dataLength );
        return dataLength;
    }

	In 0.6.3, the function reads as follows:
	
 int readBytesDirectWireFormat(InputStream in, int byteCount) throws
IOException {
        int pad = dataOffset - (HEADER_LENGTH + 3 + wordCount * 2);
        in.skip(pad);
        in.read(b, off, dataLength);
        return pad + dataLength;
    }

In the case of 0 bytes of file data and 1 byte of padding, the function
returns 1 in 0.6.3 and 0 in 1.0.1. The invoking code -
AndXServerMessageBlock::readAndXWireFormat() -  interprets a return code
of 0 as "no data read", and gets stuck - and eventually times out -
trying to read more data.

The problem goes away if I change the 1.0.1 code as follows:

	return dataLength + pad;

Any thoughts? If this is a bug, how can I report it to the JCIFS
developers?

Thanks,
Alessandro


More information about the jcifs mailing list