]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: smbd: Change smb2_file_link_information() to use srvstr_pull_talloc()/check_path_...
authorJeremy Allison <jra@samba.org>
Mon, 27 Mar 2023 18:25:59 +0000 (11:25 -0700)
committerRalph Boehme <slow@samba.org>
Fri, 31 Mar 2023 05:12:32 +0000 (05:12 +0000)
It now looks like all other SMB2 path processing and
we can proceed to strip the DFS prefixes from SMB2 pathnames
before further processing.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/smb2_trans2.c

index 0155a5a2fbaab2214d7f490dea5517b233718a39..f9544cddb72f0d94989f3b1e84b4539fc5b6483c 100644 (file)
@@ -4518,6 +4518,8 @@ static NTSTATUS smb2_file_link_information(connection_struct *conn,
        struct smb_filename *smb_fname_dst = NULL;
        NTSTATUS status = NT_STATUS_OK;
        uint32_t ucf_flags = ucf_flags_from_smb_request(req);
+       size_t ret;
+       bool is_dfs = (req->flags2 & FLAGS2_DFS_PATHNAMES);
        TALLOC_CTX *ctx = talloc_tos();
 
        if (!fsp) {
@@ -4535,26 +4537,19 @@ static NTSTATUS smb2_file_link_information(connection_struct *conn,
                return NT_STATUS_INVALID_PARAMETER;
        }
 
-       if (smb_fname_src->flags & SMB_FILENAME_POSIX_PATH) {
-               srvstr_get_path_posix(ctx,
-                               pdata,
-                               req->flags2,
-                               &newname,
-                               &pdata[20],
-                               len,
-                               STR_TERMINATE,
-                               &status);
-               ucf_flags |= UCF_POSIX_PATHNAMES;
-       } else {
-               srvstr_get_path(ctx,
-                               pdata,
-                               req->flags2,
-                               &newname,
-                               &pdata[20],
-                               len,
-                               STR_TERMINATE,
-                               &status);
+       ret = srvstr_pull_talloc(ctx,
+                                pdata,
+                                req->flags2,
+                                &newname,
+                                &pdata[20],
+                                 len,
+                                STR_TERMINATE);
+
+        if (ret == (size_t)-1 || newname == NULL) {
+               return NT_STATUS_INVALID_PARAMETER;
        }
+
+       status = check_path_syntax_smb2(newname, is_dfs);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }