From patchwork Fri Apr 17 15:17:32 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suresh Jayaraman X-Patchwork-Id: 18698 Received: from lists.samba.org (mail.samba.org [66.70.73.150]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n3HFI4RN029221 for ; Fri, 17 Apr 2009 15:18:05 GMT Received: from dp.samba.org (localhost [127.0.0.1]) by lists.samba.org (Postfix) with ESMTP id 0BA7A163D77 for ; Fri, 17 Apr 2009 15:17:44 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on dp.samba.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=3.8 tests=BAYES_00 autolearn=ham version=3.1.7 X-Original-To: linux-cifs-client@lists.samba.org Delivered-To: linux-cifs-client@lists.samba.org Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by lists.samba.org (Postfix) with ESMTP id 92710163B84 for ; Fri, 17 Apr 2009 15:17:26 +0000 (GMT) Received: from Relay2.suse.de (mail2.suse.de [195.135.221.8]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 8D7505FC9F; Fri, 17 Apr 2009 17:17:44 +0200 (CEST) Message-ID: <49E89D8C.8070002@suse.de> Date: Fri, 17 Apr 2009 20:47:32 +0530 From: Suresh Jayaraman User-Agent: Thunderbird 2.0.0.19 (X11/20081227) MIME-Version: 1.0 To: Steve French X-Enigmail-Version: 0.95.7 Cc: "linux-cifs-client@lists.samba.org" , Jeff Layton Subject: [linux-cifs-client] [PATCH 4/5] cifs: Make cifs_readdir use the helpers X-BeenThere: linux-cifs-client@lists.samba.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: The Linux CIFS VFS client List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-cifs-client-bounces+patchwork-cifs-client=patchwork.kernel.org@lists.samba.org Errors-To: linux-cifs-client-bounces+patchwork-cifs-client=patchwork.kernel.org@lists.samba.org We need to get the string from current_entry before calling UniStrnlenBytes() Signed-off-by: Suresh Jayaraman --- fs/cifs/readdir.c | 16 +++++++++------- 1 files changed, 9 insertions(+), 7 deletions(-) Index: cifs-2.6.git/fs/cifs/readdir.c =================================================================== --- cifs-2.6.git.orig/fs/cifs/readdir.c +++ cifs-2.6.git/fs/cifs/readdir.c @@ -995,8 +995,10 @@ int cifs_readdir(struct file *file, void char *current_entry; int num_to_fill = 0; char *tmp_buf = NULL; - char *end_of_smb; - int max_len; + char *end_of_smb, *filename; + int max_len, nchars; + size_t nbytes; + FILE_UNIX_INFO *punix_info; xid = GetXid(); @@ -1070,11 +1072,12 @@ int cifs_readdir(struct file *file, void cifsFile->srch_inf.ntwrk_buf_start); end_of_smb = cifsFile->srch_inf.ntwrk_buf_start + max_len; - /* To be safe - for UCS to UTF-8 with strings loaded - with the rare long characters alloc more to account for - such multibyte target UTF-8 characters. cifs_unicode.c, - which actually does the conversion, has the same limit */ - tmp_buf = kmalloc((2 * NAME_MAX) + 4, GFP_KERNEL); + /* compute the actual length in bytes required and use it */ + punix_info = (FILE_UNIX_INFO *)current_entry; + filename = &punix_info->FileName[0]; + nbytes = UniStrnlenBytes((wchar_t *)filename, 2*NAME_MAX, + &nchars, cifs_sb->local_nls); + tmp_buf = kmalloc(nbytes + 2, GFP_KERNEL); for (i = 0; (i < num_to_fill) && (rc == 0); i++) { if (current_entry == NULL) { /* evaluate whether this case is an error */