Skip to contentSkip to conversation

cifs: alloc_path_with_tree_prefix: do not append sep. if the path is empty

PATCH In review Eugene Korenevsky 1 participant 1 message Jan 14, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 cifs: alloc_path_with_tree_prefix: do not append sep. if the path is empty

alloc_path_with_tree_prefix() concatenates tree prefix and the path. Windows CIFS client does not add 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.

---
v2: The patch is included in the patchset for #215440 fix

 fs/cifs/smb2pdu.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
fs/cifs/smb2pdu.c +7 -2
index 8b3670388cda..88ea0163257c 100644
@@ -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;
Signature · 1 line
2.30.2