--------------------------------------------------------------------------------------
One tricky part of SMB is string alignment. All UCS2 strings start on
a 2 byte boundary, which sounds fine. The problem is, what is the
alignment compared with? The protocol defines it as being relative to
the start of the SMB packet but that can be tricky to get to when you
are down deep in a sub-protocol such as NTTRANS.
In most cases in Samba 3.0 we cope with this using the base_ptr passed
to the pull/push functions. This provides the base of the SMB packet,
so we know how to align any UCS2 string. In some rare cases where this
pointer is not available we assume that allocated memory will be at
least 2 byte aligned. While this is a nasty hack, it does make the
code much simpler in a few cases.
The other problem is UCS2 strings that are not aligned. We have so far
found 2 places where this happens, one is the workgroup at the end of
the NT1 negprot reply and the other is the info level 2 trans2 directory
entry. I suspect we will find more cases when Samba 3.0 becomes widely
deployed.
--------------------------------------------------------------------------------------
CIFS2001 Seattle
tridge@valinux.com