From 99fa20b418fac0f1fa1571a4bd1ad50757e822a1 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 23 Oct 2024 14:14:39 +0200 Subject: [PATCH] smbd: Fix following symlinks if basedir != cwd_fsp Unused so far, but soon we'll call this routine with a basedir that's somewhere below the share root. Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- source3/smbd/filename.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c index 2ae6edde4c3..6884802a74b 100644 --- a/source3/smbd/filename.c +++ b/source3/smbd/filename.c @@ -1079,6 +1079,7 @@ NTSTATUS filename_convert_dirfsp( struct symlink_reparse_struct *lnk = NULL; NTSTATUS status; char *target = NULL; + char *base_name = NULL; char *safe_target = NULL; size_t symlink_redirects = 0; int ret; @@ -1146,9 +1147,13 @@ next: return map_nt_error_from_unix(ret); } + if (basedir != conn->cwd_fsp) { + base_name = basedir->fsp_name->base_name; + } + status = safe_symlink_target_path(mem_ctx, conn->connectpath, - NULL, + base_name, target, lnk->unparsed_path_length, &safe_target); @@ -1157,6 +1162,7 @@ next: return status; } name_in = safe_target; + basedir = conn->cwd_fsp; symlink_redirects += 1;