From patchwork Wed Dec 29 21:32:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugene Korenevsky X-Patchwork-Id: 1574043 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-cifs-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by bilbo.ozlabs.org (Postfix) with ESMTP id 4JPPks6Zwwz9s3q for ; Thu, 30 Dec 2021 08:32:37 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232366AbhL2Vcg (ORCPT ); Wed, 29 Dec 2021 16:32:36 -0500 Received: from mail.astralinux.ru ([217.74.38.119]:41918 "EHLO mail.astralinux.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231322AbhL2Vcg (ORCPT ); Wed, 29 Dec 2021 16:32:36 -0500 X-Greylist: delayed 399 seconds by postgrey-1.27 at vger.kernel.org; Wed, 29 Dec 2021 16:32:35 EST Received: from localhost (localhost [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id C96052FA8066; Thu, 30 Dec 2021 00:32:34 +0300 (MSK) Received: from mail.astralinux.ru ([127.0.0.1]) by localhost (rbta-msk-vsrv-mail01.astralinux.ru [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id VA3HS0ZxnR7w; Thu, 30 Dec 2021 00:32:34 +0300 (MSK) Received: from localhost (localhost [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id 466972FA8069; Thu, 30 Dec 2021 00:32:34 +0300 (MSK) X-Virus-Scanned: amavisd-new at astralinux.ru Received: from mail.astralinux.ru ([127.0.0.1]) by localhost (rbta-msk-vsrv-mail01.astralinux.ru [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id JeSdrgKkN6fo; Thu, 30 Dec 2021 00:32:34 +0300 (MSK) Received: from himera.home (37-145-209-165.broadband.corbina.ru [37.145.209.165]) by mail.astralinux.ru (Postfix) with ESMTPSA id EFC212FA8066; Thu, 30 Dec 2021 00:32:33 +0300 (MSK) Date: Thu, 30 Dec 2021 00:32:32 +0300 From: Eugene Korenevsky To: linux-cifs@vger.kernel.org Cc: Steve French Subject: [PATCH] cifs: alloc_path_with_tree_prefix: do not append sep. if the path is empty Message-ID: MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org 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 --- 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;