[jcifs] Even-byte-alignment padding in Write AndX Request

David D. Kilzer ddkilzer at kilzer.net
Fri Jul 16 03:12:21 GMT 2004

I've now got a full packet returning via Read AndX Response!!  But I'm
getting an IndexOutOfBoundsException now (such is progress):

	at java.io.PushbackInputStream.read(PushbackInputStream.java:143)
	at jcifs.smb.SmbComReadAndXResponse.readBytesDirectWireFormat(SmbComReadAndXResponse.java:68)
	at jcifs.smb.AndXServerMessageBlock.readAndXWireFormat(AndXServerMessageBlock.java:266)
	at jcifs.smb.AndXServerMessageBlock.readWireFormat(AndXServerMessageBlock.java:103)
	at jcifs.smb.SmbTransport.run(SmbTransport.java:444)
	at java.lang.Thread.run(Thread.java:536)

A quick debugging session showed that the code is dying in line 3 of
SmbComReadAndXResponse.readBytesDirectWireFormat() because 'b' is
declared as byte[8] when 175 bytes of data are available to be read.
Oops!  I don't have time to track that down just now, but I'm hoping
that one of the developers can provide a patch fairly easily (or else
I'll go play with JCIFS some more tomorrow).

BTW, the last change I made (which triggered the above exception) was to
hard-code maxCount and minCount to 512 in the constructor and setParam()
methods of SmbComReadAndX:

  this.maxCount = minCount = 512;

Turns out that SQL Server 6.5 will only send back the number of bytes
requested by one (or both) of those fields, so when I was getting the
other error message earlier, I was only getting 1 byte back instead of
the whole TDS packet!

SQL Enterprise Manager (via its internal drivers) sets maxCount and
minCount to 512.  The other driver I started playing with sets it to
4292 (for better performance?).

Finally, it will take me a while to back out all of my changes to get
back to the "original" error message without all these hacks in jTDS and
JCIFS, but I plan on doing that once the above IndexOutOfBoundsException
issue is resolved (so that most of my hacks won't be needed).

Thanks for all the help!!

Dave (JAJH)

More information about the jcifs mailing list