All of lore.kernel.org
 help / color / mirror / Atom feed
From: ZhangGuoDong <zhang.guodong@linux.dev>
To: linkinjeon@kernel.org, pc@manguebit.org,
	ronniesahlberg@gmail.com, sprasad@microsoft.com, tom@talpey.com,
	bharathsm@microsoft.com, metze@samba.org
Cc: linux-cifs@vger.kernel.org,
	ZhangGuoDong <zhangguodong@kylinos.cn>,
	ChenXiaoSong <chenxiaosong@kylinos.cn>
Subject: [PATCH 2/2] smb/client: fix file name conversion on big-endian systems
Date: Tue, 24 Nov 2026 15:59:27 +0800	[thread overview]
Message-ID: <20261124075927.469470-3-zhang.guodong@linux.dev> (raw)
In-Reply-To: <20261124075927.469470-1-zhang.guodong@linux.dev>

From: ZhangGuoDong <zhangguodong@kylinos.cn>

Use CPU byte order for temporary UTF-16 buffers to avoid incorrect
file name conversion on big-endian architectures.

Fixes: b29103076bec ("Fix to convert SURROGATE PAIR")
Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
 fs/smb/client/cifs_unicode.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/smb/client/cifs_unicode.c b/fs/smb/client/cifs_unicode.c
index 4a8a591f4bca..264595633b1e 100644
--- a/fs/smb/client/cifs_unicode.c
+++ b/fs/smb/client/cifs_unicode.c
@@ -92,7 +92,7 @@ convert_sfm_char(const __u16 src_char, char *target)
 /*
  * cifs_mapchar - convert a host-endian char to proper char in codepage
  * @target - where converted character should be copied
- * @src_char - 2 byte host-endian source character
+ * @from - 2 byte host-endian source character
  * @cp - codepage to which character should be converted
  * @map_type - How should the 7 NTFS/SMB reserved characters be mapped to UCS2?
  *
@@ -126,7 +126,7 @@ cifs_mapchar(char *target, const __u16 *from, const struct nls_table *cp,
 	/* convert SURROGATE_PAIR and IVS */
 	if (strcmp(cp->charset, "utf8"))
 		goto unknown;
-	len = utf16s_to_utf8s(from, 3, UTF16_LITTLE_ENDIAN, target, 6);
+	len = utf16s_to_utf8s(from, 3, UTF16_HOST_ENDIAN, target, 6);
 	if (len <= 0)
 		goto unknown;
 	return len;
@@ -518,7 +518,7 @@ cifsConvertToUTF16(__le16 *target, const char *source, int srclen,
 			} else
 				goto unknown;
 			ret  = utf8s_to_utf16s(source + i, charlen,
-					       UTF16_LITTLE_ENDIAN,
+					       UTF16_HOST_ENDIAN,
 					       wchar_to, 6);
 			if (ret < 0)
 				goto unknown;
-- 
2.55.0


  parent reply	other threads:[~2026-11-24  7:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24  7:59 [PATCH 0/2] smb/client: fix byte order issues on big-endian systems ZhangGuoDong
2026-11-24  7:59 ` [PATCH 1/2] smb/client: fix little-endian values in diagnostic messages ZhangGuoDong
2026-11-24  7:59 ` ZhangGuoDong [this message]
2026-11-26 12:15 ` [PATCH 0/2] smb/client: fix byte order issues on big-endian systems Paulo Alcantara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261124075927.469470-3-zhang.guodong@linux.dev \
    --to=zhang.guodong@linux.dev \
    --cc=bharathsm@microsoft.com \
    --cc=chenxiaosong@kylinos.cn \
    --cc=linkinjeon@kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=metze@samba.org \
    --cc=pc@manguebit.org \
    --cc=ronniesahlberg@gmail.com \
    --cc=sprasad@microsoft.com \
    --cc=tom@talpey.com \
    --cc=zhangguodong@kylinos.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.