From patchwork Mon May 16 13:05:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 787982 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4GD5WAr014885 for ; Mon, 16 May 2011 13:05:32 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754117Ab1EPNFb (ORCPT ); Mon, 16 May 2011 09:05:31 -0400 Received: from mail-vw0-f46.google.com ([209.85.212.46]:39948 "EHLO mail-vw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754035Ab1EPNFa (ORCPT ); Mon, 16 May 2011 09:05:30 -0400 Received: by vws1 with SMTP id 1so3078563vws.19 for ; Mon, 16 May 2011 06:05:30 -0700 (PDT) Received: by 10.52.93.233 with SMTP id cx9mr6223086vdb.128.1305551129879; Mon, 16 May 2011 06:05:29 -0700 (PDT) Received: from salusa.poochiereds.net (cpe-076-182-054-018.nc.res.rr.com [76.182.54.18]) by mx.google.com with ESMTPS id h18sm1888030vbj.11.2011.05.16.06.05.28 (version=SSLv3 cipher=OTHER); Mon, 16 May 2011 06:05:29 -0700 (PDT) From: Jeff Layton To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, metze@samba.org Subject: [PATCH] cifs: fix cifsConvertToUCS() for the mapchars case Date: Mon, 16 May 2011 09:05:25 -0400 Message-Id: <1305551125-5867-1-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.4.4 Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 16 May 2011 13:05:32 +0000 (UTC) As Metze pointed out, commit 84cdf74e broke mapchars option: Commit "cifs: fix unaligned accesses in cifsConvertToUCS" (84cdf74e8096a10dd6acbb870dd404b92f07a756) does multiple steps in just one commit (moving the function and changing it without testing). put_unaligned_le16(temp, &target[j]); is never called for any codepoint the goes via the 'default' switch statement. As a result we put just zero (or maybe uninitialized) bytes into the target buffer. His proposed patch looks correct, but doesn't apply to the current head of the tree. This patch should also fix it. Reported-by: Stefan Metzmacher Signed-off-by: Jeff Layton --- fs/cifs/cifs_unicode.c | 14 ++++++-------- 1 files changed, 6 insertions(+), 8 deletions(-) diff --git a/fs/cifs/cifs_unicode.c b/fs/cifs/cifs_unicode.c index 23d43cd..1b2e180 100644 --- a/fs/cifs/cifs_unicode.c +++ b/fs/cifs/cifs_unicode.c @@ -277,6 +277,7 @@ cifsConvertToUCS(__le16 *target, const char *source, int srclen, for (i = 0, j = 0; i < srclen; j++) { src_char = source[i]; + charlen = 1; switch (src_char) { case 0: put_unaligned(0, &target[j]); @@ -316,16 +317,13 @@ cifsConvertToUCS(__le16 *target, const char *source, int srclen, dst_char = cpu_to_le16(0x003f); charlen = 1; } - /* - * character may take more than one byte in the source - * string, but will take exactly two bytes in the - * target string - */ - i += charlen; - continue; } + /* + * character may take more than one byte in the source string, + * but will take exactly two bytes in the target string + */ + i += charlen; put_unaligned(dst_char, &target[j]); - i++; /* move to next char in source string */ } ctoUCS_out: