]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: smbd: Change smb_unix_read_symlink() to use a real directory fsp for SMB_VFS_READ...
authorJeremy Allison <jra@samba.org>
Wed, 10 Feb 2021 22:50:36 +0000 (14:50 -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/smbd/trans2.c

index 7ac6204f9c4ecc290bae5278230ab44c5655b9e2..f9ef056b73663b249eaef6d95705aac73ab38ca9 100644 (file)
@@ -4957,6 +4957,9 @@ static NTSTATUS smb_unix_read_symlink(connection_struct *conn,
        NTSTATUS status;
        size_t len = 0;
        int link_len = 0;
+       struct smb_filename *parent_fname = NULL;
+       struct smb_filename *base_name = NULL;
+
        char *buffer = talloc_array(talloc_tos(), char, PATH_MAX+1);
 
        if (!buffer) {
@@ -4971,12 +4974,24 @@ static NTSTATUS smb_unix_read_symlink(connection_struct *conn,
                return NT_STATUS_DOS(ERRSRV, ERRbadlink);
        }
 
-       link_len = SMB_VFS_READLINKAT(conn,
+       status = parent_pathref(talloc_tos(),
                                conn->cwd_fsp,
                                smb_fname,
+                               &parent_fname,
+                               &base_name);
+       if (!NT_STATUS_IS_OK(status)) {
+               TALLOC_FREE(buffer);
+               return status;
+       }
+
+       link_len = SMB_VFS_READLINKAT(conn,
+                               parent_fname->fsp,
+                               base_name,
                                buffer,
                                PATH_MAX);
 
+       TALLOC_FREE(parent_fname);
+
        if (link_len == -1) {
                TALLOC_FREE(buffer);
                return map_nt_error_from_unix(errno);