From b89c0a6d3f456fe597949b660a3c2ddbbad2be42 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 29 Sep 2020 13:08:01 -0700 Subject: [PATCH] s3: smbd: SMB1 rename_internals() can figure out the wildcard status of the paths by itself. No need to pass them as parameters. Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme --- source3/smbd/nttrans.c | 2 -- source3/smbd/proto.h | 2 -- source3/smbd/reply.c | 18 ++++++++++++++---- source3/smbd/trans2.c | 2 -- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index e8f41bea99d..b6ac11f4633 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -1843,8 +1843,6 @@ void reply_ntrename(struct smb_request *req) dst_original_lcomp, attrs, false, - false, /* src_has_wcard */ - dest_has_wcard, DELETE_ACCESS); break; case RENAME_FLAG_HARD_LINK: diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index b2dfdb21b1b..dafe448e3a8 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -1050,8 +1050,6 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx, const char *dst_original_lcomp, uint32_t attrs, bool replace_if_exists, - bool src_has_wild, - bool dest_has_wild, uint32_t access_mask); void reply_mv(struct smb_request *req); NTSTATUS copy_file(TALLOC_CTX *ctx, diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index a3110fb0a62..6dc00c750ef 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -7964,8 +7964,6 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx, const char *dst_original_lcomp, uint32_t attrs, bool replace_if_exists, - bool src_has_wild, - bool dest_has_wild, uint32_t access_mask) { char *fname_src_dir = NULL; @@ -7981,6 +7979,8 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx, bool posix_pathnames = (req != NULL && req->posix_pathnames); struct smb2_create_blobs *posx = NULL; int rc; + bool src_has_wild = false; + bool dest_has_wild = false; /* * Split the old name into directory and last component @@ -7999,6 +7999,18 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx, goto out; } + if (req != NULL && !req->posix_pathnames) { + /* + * Check the wildcard mask *before* + * unmangling. As mangling is done + * for names that can't be returned + * to Windows the unmangled name may + * contain Windows wildcard characters. + */ + src_has_wild = ms_has_wild(fname_src_mask); + dest_has_wild = ms_has_wild(dst_original_lcomp); + } + /* * We should only check the mangled cache * here if unix_convert failed. This means @@ -8471,8 +8483,6 @@ void reply_mv(struct smb_request *req) dst_original_lcomp, attrs, false, - src_has_wcard, - dest_has_wcard, DELETE_ACCESS); if (!NT_STATUS_IS_OK(status)) { if (open_was_deferred(req->xconn, req->mid)) { diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index f4bcd5ae2cb..d76e8fc8ffb 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -7501,8 +7501,6 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn, dst_original_lcomp, 0, overwrite, - false, - dest_has_wcard, FILE_WRITE_ATTRIBUTES); } out: