[linux-cifs-client] Re: [PATCH 00/12] cifs: fix string conversions from wire format to local charset (try #3)

Steve French smfrench at gmail.com
Thu Apr 30 23:48:51 GMT 2009


Forgot to cc the list

On Thu, Apr 30, 2009 at 6:48 PM, Steve French <smfrench at gmail.com> wrote:
> On Thu, Apr 30, 2009 at 5:55 PM, Jeff Layton <jlayton at redhat.com> wrote:
>> On Thu, 30 Apr 2009 16:39:25 -0500
>> Steve French <smfrench at gmail.com> wrote:
>>
>>> Have merged Jeff's fixes (minus the two which don't fix string conversions).
>>>
>>> I removed the dead code in sessionsetup functions in connect.c (about
>>> 450 lines), except the 2 ntlmssp functions which I will rewrite
>>> tonight or tomorrow, but there are some problems that the patch
>>> testing uncovered:
>>>
>>> 1) readdir (findfirst level 257, in which strings are length delimited
>>> rather than null terminated) doesn't seem to handle files which are
>>> not null terminated (causing extra characters to appear at the end of
>>> some file names)
>>>
>>
>> That's probably my fault. I think the old code used the length that it
>> got from the server calculate the length that it passed to
>> cifs_strfromUCS_le. I assumed that the string would be null terminated
>> and figured that it would be safer to pass in the distance to the end
>> of the response as a max length. We probably just need to change it to
>> use:
>>
>> min(length_from_server, distance_to_end_of_packet)
>>
>> That should do the right thing and still be safe. I'll code up a patch
>> later tonight or tomorrow that does that and test it out.
>
> The code that changed was in fs/cifs/readdir.c
>
> -                       pqst->len = cifs_strfromUCS_le((char *)pqst->name,
> -                                       (__le16 *)filename, len/2, nlt);
> +               pqst->len = cifs_from_ucs2((char *) pqst->name,
> +                                          (__le16 *) filename,
> +                                          UNICODE_NAME_MAX, max_len, nlt,
> +                                          cifs_sb->mnt_cifs_flags &
> +                                               CIFS_MOUNT_MAP_SPECIAL_CHR);
>
>
So min of max_len and len should be fine.  I simply changed max_len to
len and that seems to work.



-- 
Thanks,

Steve


More information about the linux-cifs-client mailing list