From 01f268bdfbebbad1172b6de17cfca1e0097a047b Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 17 Sep 2025 15:46:37 -0700 Subject: [PATCH] smbd: Return newname from smb2_parse_file_rename_information() Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- source3/smbd/proto.h | 24 +++++++++++++----------- source3/smbd/smb2_setinfo.c | 4 ++++ source3/smbd/smb2_trans2.c | 27 ++++++++++++++++----------- 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index b9e598810c3..ee2d8294a10 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -1136,17 +1136,19 @@ NTSTATUS smb_set_fsquota(connection_struct *conn, files_struct *fsp, const DATA_BLOB *qdata); -NTSTATUS smb2_parse_file_rename_information(TALLOC_CTX *ctx, - struct connection_struct *conn, - struct smb_request *req, - const char *pdata, - int total_data, - files_struct *fsp, - struct smb_filename *smb_fname_src, - bool *overwrite, - struct files_struct **_dst_dirfsp, - struct smb_filename **_smb_fname_dst, - char **_dst_original_lcomp); +NTSTATUS smb2_parse_file_rename_information( + TALLOC_CTX *ctx, + struct connection_struct *conn, + struct smb_request *req, + const char *pdata, + int total_data, + files_struct *fsp, + struct smb_filename *smb_fname_src, + char **_newname, + bool *overwrite, + struct files_struct **_dst_dirfsp, + struct smb_filename **_smb_fname_dst, + char **_dst_original_lcomp); /* The following definitions come from smbd/uid.c */ diff --git a/source3/smbd/smb2_setinfo.c b/source3/smbd/smb2_setinfo.c index b6256907c9c..522e10e92f6 100644 --- a/source3/smbd/smb2_setinfo.c +++ b/source3/smbd/smb2_setinfo.c @@ -577,6 +577,7 @@ static void smbd_smb2_setinfo_rename_dst_check(struct tevent_req *req) req, struct smbd_smb2_setinfo_state); struct tevent_req *subreq = NULL; struct timeval timeout; + char *newname = NULL; bool overwrite = false; struct files_struct *fsp = state->fsp; struct files_struct *dst_dirfsp = NULL; @@ -601,6 +602,7 @@ static void smbd_smb2_setinfo_rename_dst_check(struct tevent_req *req) state->data.length, fsp, fsp->fsp_name, + &newname, &overwrite, &dst_dirfsp, &smb_fname_dst, @@ -788,6 +790,7 @@ static void smbd_smb2_setinfo_rename_dst_parent_check(struct tevent_req *req) req, struct smbd_smb2_setinfo_state); struct tevent_req *subreq = NULL; struct timeval timeout; + char *newname = NULL; bool overwrite = false; struct files_struct *fsp = state->fsp; struct files_struct *dst_parent_dirfsp = NULL; @@ -813,6 +816,7 @@ static void smbd_smb2_setinfo_rename_dst_parent_check(struct tevent_req *req) state->data.length, fsp, fsp->fsp_name, + &newname, &overwrite, &dst_parent_dirfsp, &smb_fname_dst, diff --git a/source3/smbd/smb2_trans2.c b/source3/smbd/smb2_trans2.c index 13b3689197f..f5d2737e01b 100644 --- a/source3/smbd/smb2_trans2.c +++ b/source3/smbd/smb2_trans2.c @@ -4237,17 +4237,19 @@ static NTSTATUS smb_file_mode_information(connection_struct *conn, Deal with SMB2_FILE_RENAME_INFORMATION_INTERNAL ****************************************************************************/ -NTSTATUS smb2_parse_file_rename_information(TALLOC_CTX *ctx, - struct connection_struct *conn, - struct smb_request *req, - const char *pdata, - int total_data, - files_struct *fsp, - struct smb_filename *smb_fname_src, - bool *_overwrite, - struct files_struct **_dst_dirfsp, - struct smb_filename **_smb_fname_dst, - char **_dst_original_lcomp) +NTSTATUS smb2_parse_file_rename_information( + TALLOC_CTX *ctx, + struct connection_struct *conn, + struct smb_request *req, + const char *pdata, + int total_data, + files_struct *fsp, + struct smb_filename *smb_fname_src, + char **_newname, + bool *_overwrite, + struct files_struct **_dst_dirfsp, + struct smb_filename **_smb_fname_dst, + char **_dst_original_lcomp) { char *newname = NULL; struct files_struct *dst_dirfsp = NULL; @@ -4339,6 +4341,7 @@ NTSTATUS smb2_parse_file_rename_information(TALLOC_CTX *ctx, } done: + *_newname = newname; *_overwrite = overwrite; *_dst_dirfsp = dst_dirfsp; *_smb_fname_dst = smb_fname_dst; @@ -4354,6 +4357,7 @@ static NTSTATUS smb2_file_rename_information(connection_struct *conn, struct share_mode_lock **lck, struct smb_filename *smb_fname_src) { + char *newname = NULL; bool overwrite; struct files_struct *dst_dirfsp = NULL; struct smb_filename *smb_fname_dst = NULL; @@ -4368,6 +4372,7 @@ static NTSTATUS smb2_file_rename_information(connection_struct *conn, total_data, fsp, smb_fname_src, + &newname, &overwrite, &dst_dirfsp, &smb_fname_dst, -- 2.47.3