[linux-cifs-client] Null-Terminating bcc_ptr wrong?

Peter Hudec PeterHudec at web.de
Fri Apr 10 15:02:01 GMT 2009


Christopher R. Hertel wrote:
> This is a tangent, but...
>
> It shouldn't be UTF-8.  CIFS (the protocol) supports UCS-16LE Unicode
> encoding or 8-bit extended ASCII (OEM charset).
>
> Chris -)-----
The protocol SMB/CIFS uses UCS-2LE (to be correct), but the conversion 
may be done to UTF-8.

The UCS-2LE-string from the packet can grow up to 4 bytes/character or 
twice as big as UCS-2LE (it can - it does not neccessarily do so!)

To determine the size of the target buffer without calculating it the 
correct line should be:

tcon->nativeFileSystem = kzalloc(4 * (length + 1), GFP_KERNEL);

tcon->nativeFileSystem is a buffer in the specific codepage. If it is ISO 5598-1, e.g., it is fine, because it needs 8 bit (1 byte) per character. If it is UTF-8, and only consists of ASCII (like "NTFS", "FAT32"), it is fine too and only needs one byte per character.
But in a worse case (is there any file system containing special characters? I don't know any) the buffer can grow up to 4 bytes per character.


Peter



More information about the linux-cifs-client mailing list