]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Slightly simplify reply_ntrename()
authorVolker Lendecke <vl@samba.org>
Sun, 14 Sep 2025 17:23:38 +0000 (10:23 -0700)
committerRalph Boehme <slow@samba.org>
Tue, 21 Oct 2025 17:33:29 +0000 (17:33 +0000)
We call filename_convert_dirfsp() on the old name. Use the parsing
done there, we don't need to scan for a ":" in reply_ntrename() where
filename_convert_dirfsp() already does it.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/smb1_nttrans.c

index 61f9c82f1850e90b51f472cf06bdb2fac31da656..c793c359dc97b11405935e665eb01e193e4c924c 100644 (file)
@@ -1434,7 +1434,6 @@ void reply_ntrename(struct smb_request *req)
        NTTIME dst_twrp = 0;
        uint16_t rename_type;
        TALLOC_CTX *ctx = talloc_tos();
-       bool stream_rename = false;
 
        START_PROFILE(SMBntrename);
 
@@ -1472,18 +1471,6 @@ void reply_ntrename(struct smb_request *req)
                goto out;
        }
 
-       if (!req->posix_pathnames) {
-               /* The newname must begin with a ':' if the
-                  oldname contains a ':'. */
-               if (strchr_m(oldname, ':')) {
-                       if (newname[0] != ':') {
-                               reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
-                               goto out;
-                       }
-                       stream_rename = true;
-               }
-       }
-
        if (ucf_flags_src & UCF_GMT_PATHNAME) {
                extract_snapshot_token(oldname, &src_twrp);
        }
@@ -1512,7 +1499,12 @@ void reply_ntrename(struct smb_request *req)
                goto out;
        }
 
-       if (stream_rename) {
+       if (!req->posix_pathnames && is_named_stream(smb_fname_old)) {
+               if (newname[0] != ':') {
+                       reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
+                       goto out;
+               }
+
                /*
                 * No point in calling filename_convert()
                 * on a raw stream name. It can never find