]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libsmb: Make a r/w copy of fname in cli_smb2_create_fnum_send()
authorVolker Lendecke <vl@samba.org>
Thu, 15 Dec 2022 17:54:58 +0000 (18:54 +0100)
committerVolker Lendecke <vl@samba.org>
Fri, 16 Dec 2022 07:42:38 +0000 (07:42 +0000)
We're messing with this in 2 places in this routine and have to make a
copy in both places. Make this writable, so we don't have to make a
copy further down.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/libsmb/cli_smb2_fnum.c

index bb99201bb61094be70d4c057be9e6a95661e39f3..084aef283cb96c02b00fa137941b3ab849c6a2ba 100644 (file)
@@ -158,9 +158,9 @@ static uint8_t flags_to_smb2_oplock(uint32_t create_flags)
  if this hasn't already been done.
 ***************************************************************/
 
-static const char *smb2_dfs_share_path(TALLOC_CTX *ctx,
-                                      struct cli_state *cli,
-                                      const char *path)
+static char *smb2_dfs_share_path(TALLOC_CTX *ctx,
+                                struct cli_state *cli,
+                                char *path)
 {
        bool is_dfs = smbXcli_conn_dfs_supported(cli->conn) &&
                        smbXcli_tcon_is_dfs_share(cli->smb2.tcon);
@@ -210,7 +210,7 @@ struct tevent_req *cli_smb2_create_fnum_send(
        TALLOC_CTX *mem_ctx,
        struct tevent_context *ev,
        struct cli_state *cli,
-       const char *fname,
+       const char *fname_in,
        uint32_t create_flags,
        uint32_t impersonation_level,
        uint32_t desired_access,
@@ -222,6 +222,7 @@ struct tevent_req *cli_smb2_create_fnum_send(
 {
        struct tevent_req *req, *subreq;
        struct cli_smb2_create_fnum_state *state;
+       char *fname = NULL;
        size_t fname_len = 0;
        const char *startp = NULL;
        const char *endp = NULL;
@@ -235,6 +236,11 @@ struct tevent_req *cli_smb2_create_fnum_send(
        }
        state->cli = cli;
 
+       fname = talloc_strdup(state, fname_in);
+       if (tevent_req_nomem(fname, req)) {
+               return tevent_req_post(req, ev);
+       }
+
        if (cli->backup_intent) {
                create_options |= FILE_OPEN_FOR_BACKUP_INTENT;
        }