unicode filename in NTCreateAndX

Alison Winters alisonw at sgi.com
Wed Nov 29 03:26:39 GMT 2006

Hi all,

I've been playing around with the pcap2nbench tool in Samba 3_0 and
noticed it wasn't picking up any of the filenames my WinXP desktop was
requesting.  A quick look at the network trace showed the filenames
appear to be coming in UCS-2 (or similar) encoding.  The bit of code
that grabs the filenames as it stands is:

file_name = (const char *) (data + 51);

where file_name is a std::string.  Which doesn't work.  After much
futzing around yesterday and realizing wchar_t is 4 bytes (!) in Linux i
figured the easiest way to grab that string would be to parse it back to
a regular std::string/char * by skipping over every nul byte.  This
kindasorta works for what i need to do with the tool, but it'd be nice
to do this properly and submit the fix upstream.

What i'm wondering is the following...

1. What clients send UCS-2-encoded filenames?
2. How do i tell from the server side what to expect?
   (memchr(data + 51, 0, file_name_len) is kinda a lame test)
3. Is it possible sometimes the first byte of the UCS-2 string is
   uninitialized?  Is this one of those weird freaky alignment things?
4. Is there a non-sucking way to cast a byte array input stream to a
   proper unicode string in STL?


More information about the samba-technical mailing list