]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: VFS: cap: Fix cap_readlinkat() to cope with real directory fsps.
authorJeremy Allison <jra@samba.org>
Thu, 11 Feb 2021 17:21:41 +0000 (09:21 -0800)
committerJeremy Allison <jra@samba.org>
Sat, 13 Feb 2021 00:17:31 +0000 (00:17 +0000)
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
source3/modules/vfs_cap.c

index 0975742598ce577c59c6f04b1258a0ffeff008e6..95b6087d41c5aad838b99d033b6d6b667527232d 100644 (file)
@@ -553,12 +553,22 @@ static int cap_readlinkat(vfs_handle_struct *handle,
                        char *buf,
                        size_t bufsiz)
 {
-       char *cappath = capencode(talloc_tos(), smb_fname->base_name);
+       struct smb_filename *full_fname = NULL;
        struct smb_filename *cap_smb_fname = NULL;
+       char *cappath = NULL;
        int saved_errno = 0;
        int ret;
 
-       if (!cappath) {
+       full_fname = full_path_from_dirfsp_atname(talloc_tos(),
+                                               dirfsp,
+                                               smb_fname);
+       if (full_fname == NULL) {
+               return -1;
+       }
+
+       cappath = capencode(talloc_tos(), full_fname->base_name);
+       if (cappath == NULL) {
+               TALLOC_FREE(full_fname);
                errno = ENOMEM;
                return -1;
        }
@@ -569,18 +579,20 @@ static int cap_readlinkat(vfs_handle_struct *handle,
                                        smb_fname->twrp,
                                        smb_fname->flags);
        if (cap_smb_fname == NULL) {
+               TALLOC_FREE(full_fname);
                TALLOC_FREE(cappath);
                errno = ENOMEM;
                return -1;
        }
        ret = SMB_VFS_NEXT_READLINKAT(handle,
-                       dirfsp,
+                       handle->conn->cwd_fsp,
                        cap_smb_fname,
                        buf,
                        bufsiz);
        if (ret == -1) {
                saved_errno = errno;
        }
+       TALLOC_FREE(full_fname);
        TALLOC_FREE(cappath);
        TALLOC_FREE(cap_smb_fname);
        if (saved_errno != 0) {