From: Volker Lendecke Date: Sun, 14 Sep 2025 17:23:38 +0000 (-0700) Subject: smbd: Slightly simplify reply_ntrename() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=396e278e2230dd8502ae5186b7623a91dfcdcbed;p=thirdparty%2Fsamba.git smbd: Slightly simplify reply_ntrename() 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 Reviewed-by: Ralph Boehme --- diff --git a/source3/smbd/smb1_nttrans.c b/source3/smbd/smb1_nttrans.c index 61f9c82f185..c793c359dc9 100644 --- a/source3/smbd/smb1_nttrans.c +++ b/source3/smbd/smb1_nttrans.c @@ -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