From c0492a46bb4b9a3d5069120adfbb668eab7dd650 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 26 Oct 2023 16:12:29 +0200 Subject: [PATCH] smbd: Fix read_symlink_reparse() Bug: https://bugzilla.samba.org/show_bug.cgi?id=15505 Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Fri Oct 27 21:19:35 UTC 2023 on atb-devel-224 (cherry picked from commit 952d6c2cf48b19807e96a49b95c19c224bd6e732) --- source3/smbd/files.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/source3/smbd/files.c b/source3/smbd/files.c index 9dcab463d3b..b8640fd6677 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -754,11 +754,19 @@ NTSTATUS read_symlink_reparse( } if (symlink->substitute_name[0] == '/') { - const char *connectpath = dirfsp->conn->connectpath; + char *subdir_path = NULL; char *abs_target_canon = NULL; const char *relative = NULL; bool in_share; + subdir_path = talloc_asprintf(talloc_tos(), + "%s/%s", + dirfsp->conn->connectpath, + dirfsp->fsp_name->base_name); + if (subdir_path == NULL) { + goto nomem; + } + abs_target_canon = canonicalize_absolute_path(talloc_tos(), symlink->substitute_name); @@ -766,8 +774,8 @@ NTSTATUS read_symlink_reparse( goto nomem; } - in_share = subdir_of(connectpath, - strlen(connectpath), + in_share = subdir_of(subdir_path, + strlen(subdir_path), abs_target_canon, &relative); if (in_share) { -- 2.38.0