s3: smbd: Use get_original_lcomp() inside smb2_file_rename_information().
authorJeremy Allison <jra@samba.org>
Thu, 26 Mar 2020 22:59:51 +0000 (15:59 -0700)
committerRalph Boehme <slow@samba.org>
Mon, 30 Mar 2020 14:45:31 +0000 (14:45 +0000)
Pass to rename_internals_fsp(). Note this is a logic change,
as the original code only set smb_fname->original_lcomp if
it was doing a stream rename. Inside rename_internals_fsp()
we only look at original_lcomp in the stream rename case, so
this code worked. However, it is much safer to always correctly
create dst_original_lcomp than pass in a NULL here. It won't
hurt if it's not actually looked at.

Removes one more use of the struct member original_lcomp.

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

index bbb894c1af37e0a8eb98692b8ea700c538ee31a1..21b04d45258f7208cdd3da3b1da461056241f551 100644 (file)
@@ -7083,6 +7083,7 @@ static NTSTATUS smb2_file_rename_information(connection_struct *conn,
        uint32_t len;
        char *newname = NULL;
        struct smb_filename *smb_fname_dst = NULL;
+       const char *dst_original_lcomp = NULL;
        uint32_t ucf_flags = UCF_SAVE_LCOMP |
                ucf_flags_from_smb_request(req);
        NTSTATUS status = NT_STATUS_OK;
@@ -7156,18 +7157,19 @@ static NTSTATUS smb2_file_rename_information(connection_struct *conn,
                        status = NT_STATUS_NO_MEMORY;
                        goto out;
                }
+       }
 
-               /*
-                * Set the original last component, since
-                * rename_internals_fsp() requires it.
-                */
-               smb_fname_dst->original_lcomp = talloc_strdup(smb_fname_dst,
-                                                             newname);
-               if (smb_fname_dst->original_lcomp == NULL) {
-                       status = NT_STATUS_NO_MEMORY;
-                       goto out;
-               }
-
+       /*
+        * Set the original last component, since
+        * rename_internals_fsp() requires it.
+        */
+       dst_original_lcomp = get_original_lcomp(smb_fname_dst,
+                                       conn,
+                                       newname,
+                                       ucf_flags);
+       if (dst_original_lcomp == NULL) {
+               status = NT_STATUS_NO_MEMORY;
+               goto out;
        }
 
        DEBUG(10,("smb2_file_rename_information: "
@@ -7177,7 +7179,7 @@ static NTSTATUS smb2_file_rename_information(connection_struct *conn,
        status = rename_internals_fsp(conn,
                                fsp,
                                smb_fname_dst,
-                               smb_fname_dst->original_lcomp,
+                               dst_original_lcomp,
                                (FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM),
                                overwrite);