Skip to content

Commit 466611e

Browse files
Paulo Alcantarasmfrench
authored andcommitted
cifs: fix source pathname comparison of dfs supers
We store the TCP_Server_Info::origin_fullpath path canonicalised (e.g. with '\\' path separators), so ignore separators when comparing it with smb3_fs_context::source. Signed-off-by: Paulo Alcantara (SUSE) <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent a85ceaf commit 466611e

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

fs/cifs/connect.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1412,6 +1412,20 @@ match_security(struct TCP_Server_Info *server, struct smb3_fs_context *ctx)
14121412
return true;
14131413
}
14141414

1415+
static bool dfs_src_pathname_equal(const char *s1, const char *s2)
1416+
{
1417+
if (strlen(s1) != strlen(s2))
1418+
return false;
1419+
for (; *s1; s1++, s2++) {
1420+
if (*s1 == '/' || *s1 == '\\') {
1421+
if (*s2 != '/' && *s2 != '\\')
1422+
return false;
1423+
} else if (tolower(*s1) != tolower(*s2))
1424+
return false;
1425+
}
1426+
return true;
1427+
}
1428+
14151429
/* this function must be called with srv_lock held */
14161430
static int match_server(struct TCP_Server_Info *server, struct smb3_fs_context *ctx,
14171431
bool dfs_super_cmp)
@@ -1449,7 +1463,7 @@ static int match_server(struct TCP_Server_Info *server, struct smb3_fs_context *
14491463
*/
14501464
if (dfs_super_cmp) {
14511465
if (!ctx->source || !server->origin_fullpath ||
1452-
strcasecmp(server->origin_fullpath, ctx->source))
1466+
!dfs_src_pathname_equal(server->origin_fullpath, ctx->source))
14531467
return 0;
14541468
} else {
14551469
/* Skip addr, hostname and port matching for DFS connections */

0 commit comments

Comments
 (0)