All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eugene Korenevsky <ekorenevsky@astralinux.ru>
To: linux-cifs@vger.kernel.org
Cc: Steve French <sfrench@samba.org>
Subject: [PATCH] cifs: alloc_path_with_tree_prefix: do not append sep. if the path is empty
Date: Thu, 30 Dec 2021 00:25:52 +0300	[thread overview]
Message-ID: <YczSYDk/eklOzc2e@himera.home> (raw)

alloc_path_with_tree_prefix() concatenates tree prefix and the path.
Windows CIFS client does not append separator after the tree prefix if
the path is empty. Let's do the same.

This fixes mounting DFS namespaces with names containing non-ASCII symbols.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=215440
Signed-off-by: Eugene Korenevsky <ekorenevsky@astralinux.ru>
---
 fs/cifs/smb2pdu.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 8b3670388cda..88ea0163257c 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -2527,8 +2527,13 @@ alloc_path_with_tree_prefix(__le16 **out_path, int *out_size, int *out_len,
 
 	cp = load_nls_default();
 	cifs_strtoUTF16(*out_path, treename, treename_len, cp);
-	UniStrcat(*out_path, sep);
-	UniStrcat(*out_path, path);
+
+	/* Do not append the separator if the path is empty */
+	if (path[0] != cpu_to_le16(0x0000)) {
+		UniStrcat(*out_path, sep);
+		UniStrcat(*out_path, path);
+	}
+
 	unload_nls(cp);
 
 	return 0;
-- 
2.30.2


             reply	other threads:[~2021-12-29 21:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-29 21:25 Eugene Korenevsky [this message]
2021-12-29 21:32 [PATCH] cifs: alloc_path_with_tree_prefix: do not append sep. if the path is empty Eugene Korenevsky

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=YczSYDk/eklOzc2e@himera.home \
    --to=ekorenevsky@astralinux.ru \
    --cc=linux-cifs@vger.kernel.org \
    --cc=sfrench@samba.org \
    /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.