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

Michael B Allen mba2000 at ioplex.com
Thu Jul 15 19:55:01 GMT 2004

On Thu, 15 Jul 2004 11:57:00 -0500
ddkilzer at kilzer.net (David D. Kilzer) wrote:

> Hi,
> I'm looking for help debugging an issue with named pipes and JCIFS-0.9.5.
> I believe I need to pad the data section of an SMB Write AndX Request
> packet by 1 byte, but I'm not sure how to make JCIFS go about doing
> this (or if it would even help).  Any thoughts or suggestions would be
> appreciated.  More details below.
> So I went insane yesterday and tried to incorporate JCIFS into the jTDS
> JDBC driver so that jTDS could talk to SQL Server 6.5 servers that use
> named pipe IPC.  You may read about it here:
> [ 991684 ] Implement named pipe IPC for SQL Server 6.5
> http://sourceforge.net/tracker/index.php?func=detail&aid=991684&group_id=33291&atid=407765
> I have hacked up jTDS so that it emits a TDS 4.2 logon packet (which is
> the data after the Write AndX Request) that is identical to what the SQL
> Enterprise Manager tool sends.  Unfortunately, there are still a few
> minor differences between the two packets:
>   - The SQL Enterprise Manager packet has the TDS 4.2 logon packet
>     even-byte-aligned by including a padding byte of 0xEE between the
>     Write AndX Request and the data (TDS 4.2 logon packet).
>   - Fields that differ in the SMB Header:
>     Fields        SQL-E-M   JCIFS
>     ------------- --------  --------
>     Flags2:       0xc807    0xc003

Bit 0x800 is extended security but if you're writing data then you
already authenticated successfully so I don't think this would matter.

>     Tree ID:      6150      2055
>     Process ID:   65279     50097
>     User ID:      6150      2050
>     Multiplex ID: 57601     4

No problem.

>   - Fields that differ in the Write AndX Request:
>     Fields        SQL-E-M   JCIFS
>     ------------- --------  --------
>     Reserved:     FFFFFFFF  00000000
>     Write Mode:   0x0008    0x0000

Mmm, Ethereal claims 0x0008 is "write start". We don't do anything with
that flag. Try setting writeMode = 0x0008 in the SmbComWriteAndX.java
constructor (temporarily just to see if it works).

>     Remaining:    512       0

Probably doesn't matter.

>     Data Offset:  64        63
>     Byte Count:   513       512
>     Padding:      EE        (n/a)

Alignment could be an issue. Try uncommenting
jcifs/smb/SmbComWriteAndX.java:110 where the comment reads "Netware
doesn't like this". Make it 0xEE if you like. I don't think it should
make any difference.


Greedo shoots first? Not in my Star Wars.

More information about the jcifs mailing list