From 952d6c2cf48b19807e96a49b95c19c224bd6e732 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 --- selftest/knownfail.d/bug-15505 | 1 - source3/smbd/files.c | 14 +++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) delete mode 100644 selftest/knownfail.d/bug-15505 diff --git a/selftest/knownfail.d/bug-15505 b/selftest/knownfail.d/bug-15505 deleted file mode 100644 index 9f244964047..00000000000 --- a/selftest/knownfail.d/bug-15505 +++ /dev/null @@ -1 +0,0 @@ -^samba3.blackbox.smbclient_s3.*.follow\ local\ symlinks.* \ No newline at end of file diff --git a/source3/smbd/files.c b/source3/smbd/files.c index d19cbcc0dda..1bbf822df28 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -752,11 +752,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); @@ -764,8 +772,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.47.3