[jcifs] Even-byte-alignment padding in Write AndX Request
David D. Kilzer
ddkilzer at kilzer.net
Fri Jul 16 03:34:14 GMT 2004
I couldn't wait! Attached is a patch to "fix" the buffer issue
(although it's probably not the best solution). This gets me past the
IndexOutOfBoundsException, but now I have to figure out how to
authenticate properly to SQL Server 6.5. (It doesn't like me connecting
anonymously!)
Dave
On Thu, Jul 15, 2004 at 10:12:21PM -0500, David D. Kilzer wrote:
> I've now got a full packet returning via Read AndX Response!! But I'm
> getting an IndexOutOfBoundsException now (such is progress):
>
> java.lang.IndexOutOfBoundsException
> 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).
>
> [...]
-------------- next part --------------
diff -ur jcifs-0.9.5-orig/src/jcifs/smb/SmbComReadAndXResponse.java jcifs-0.9.5/src/jcifs/smb/SmbComReadAndXResponse.java
--- jcifs-0.9.5-orig/src/jcifs/smb/SmbComReadAndXResponse.java 2004-07-01 19:11:48.000000000 -0500
+++ jcifs-0.9.5/src/jcifs/smb/SmbComReadAndXResponse.java 2004-07-15 22:27:28.494329200 -0500
@@ -65,6 +65,7 @@
byte[] buffer, int bufferIndex ) throws IOException {
int pad = dataOffset - ( HEADER_LENGTH + 3 + wordCount * 2 );
in.read( buffer, bufferIndex, pad ); /* needed for signing */
+ b = new byte[dataLength];
in.read( b, off, dataLength );
return dataLength;
}
More information about the jcifs
mailing list