Re: Null-Terminating bcc_ptr wrong?

Peter Hudec <[email protected]>
Newsgroups gmane.linux.file-systems.cifs
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.