From: Jeremy Allison Date: Thu, 11 Feb 2021 19:36:22 +0000 (-0800) Subject: s3: VFS: shadow_copy2: Fix shadow_copy2_readlinkat() to cope with real directory... X-Git-Tag: tevent-0.11.0~1756 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7973e09fd113360a5cb019666a7988fd8a639c37;p=thirdparty%2Fsamba.git s3: VFS: shadow_copy2: Fix shadow_copy2_readlinkat() to cope with real directory fsps. Signed-off-by: Jeremy Allison Reviewed-by: Noel Power --- diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c index 227ac148260..76d09587007 100644 --- a/source3/modules/vfs_shadow_copy2.c +++ b/source3/modules/vfs_shadow_copy2.c @@ -1578,26 +1578,43 @@ static int shadow_copy2_readlinkat(vfs_handle_struct *handle, char *stripped = NULL; int saved_errno = 0; int ret; + struct smb_filename *full_fname = NULL; struct smb_filename *conv = NULL; - if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, - smb_fname, - ×tamp, &stripped)) { + full_fname = full_path_from_dirfsp_atname(talloc_tos(), + dirfsp, + smb_fname); + if (full_fname == NULL) { + errno = ENOMEM; return -1; } + + if (!shadow_copy2_strip_snapshot(talloc_tos(), + handle, + full_fname, + ×tamp, + &stripped)) { + TALLOC_FREE(full_fname); + return -1; + } + if (timestamp == 0) { + TALLOC_FREE(full_fname); + TALLOC_FREE(stripped); return SMB_VFS_NEXT_READLINKAT(handle, dirfsp, smb_fname, buf, bufsiz); } - conv = cp_smb_filename(talloc_tos(), smb_fname); + conv = cp_smb_filename(talloc_tos(), full_fname); if (conv == NULL) { + TALLOC_FREE(full_fname); TALLOC_FREE(stripped); errno = ENOMEM; return -1; } + TALLOC_FREE(full_fname); conv->base_name = shadow_copy2_convert( conv, handle, stripped, timestamp); TALLOC_FREE(stripped); @@ -1605,7 +1622,7 @@ static int shadow_copy2_readlinkat(vfs_handle_struct *handle, return -1; } ret = SMB_VFS_NEXT_READLINKAT(handle, - dirfsp, + handle->conn->cwd_fsp, conv, buf, bufsiz);