]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
Fix bug #5986 - Editing a stream is broken (rename problems).
authorJeremy Allison <jra@samba.org>
Fri, 19 Dec 2008 21:58:22 +0000 (13:58 -0800)
committerKarolin Seeger <kseeger@samba.org>
Fri, 2 Jan 2009 11:44:21 +0000 (12:44 +0100)
Jeremy.
(cherry picked from commit d53aa6257d39313b1b493805a2a73774e07faf8a)

source/smbd/reply.c
source/smbd/trans2.c

index 7e8f17a286c24462b59bbabf15ae5d0e29f816ae..c0359bccaf43c9802ff683aabe0e31d4d0cee4be 100644 (file)
@@ -5582,7 +5582,9 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
        }
 
        if(replace_if_exists && dst_exists) {
-               if (is_ntfs_stream_name(newname)) {
+               /* Ensure both or neither are stream names. */
+               if (is_ntfs_stream_name(fsp->fsp_name) !=
+                               is_ntfs_stream_name(newname)) {
                        return NT_STATUS_INVALID_PARAMETER;
                }
        }
index 61d23ef954f137c37b8bcc35236ed677cb1ad6e3..406cc4e56fe8742f2f92fb14efe26de38e686bcc 100644 (file)
@@ -5353,6 +5353,8 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
        char *newname = NULL;
        char *base_name = NULL;
        bool dest_has_wcard = False;
+       SMB_STRUCT_STAT sbuf;
+       char *newname_last_component = NULL;
        NTSTATUS status = NT_STATUS_OK;
        char *p;
        TALLOC_CTX *ctx = talloc_tos();
@@ -5361,6 +5363,8 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
                return NT_STATUS_INVALID_PARAMETER;
        }
 
+       ZERO_STRUCT(sbuf);
+
        overwrite = (CVAL(pdata,0) ? True : False);
        root_fid = IVAL(pdata,4);
        len = IVAL(pdata,8);
@@ -5394,6 +5398,7 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
        }
 
        if (fsp && fsp->base_fsp) {
+               /* newname must be a stream name. */
                if (newname[0] != ':') {
                        return NT_STATUS_NOT_SUPPORTED;
                }
@@ -5404,6 +5409,7 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
                        return NT_STATUS_NO_MEMORY;
                }
        } else {
+               /* newname must *not* be a stream name. */
                if (is_ntfs_stream_name(newname)) {
                        return NT_STATUS_NOT_SUPPORTED;
                }
@@ -5429,18 +5435,11 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
                if (!base_name) {
                        return NT_STATUS_NO_MEMORY;
                }
-       }
-
-       if (fsp) {
-               SMB_STRUCT_STAT sbuf;
-               char *newname_last_component = NULL;
-
-               ZERO_STRUCT(sbuf);
 
                status = unix_convert(ctx, conn, newname, False,
-                                       &newname,
-                                       &newname_last_component,
-                                       &sbuf);
+                               &newname,
+                               &newname_last_component,
+                               &sbuf);
 
                /* If an error we expect this to be
                 * NT_STATUS_OBJECT_PATH_NOT_FOUND */
@@ -5450,7 +5449,9 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
                                        status)) {
                        return status;
                }
+       }
 
+       if (fsp) {
                DEBUG(10,("smb_file_rename_information: SMB_FILE_RENAME_INFORMATION (fnum %d) %s -> %s\n",
                        fsp->fnum, fsp->fsp_name, base_name ));
                status = rename_internals_fsp(conn, fsp, base_name,