From 5cbab2ebfdad88080c060730979725f2c6fa40cc Mon Sep 17 00:00:00 2001 From: Noel Power Date: Fri, 29 Jan 2021 14:54:47 +0000 Subject: [PATCH] s3/smbd: use smb_fname->fsp for get_ea_list_from_file_path in estimate_ea_size() Additionally ensure get_ea_list_from_file_path is called with base file. Previously fsp was set to NULL if fsp pointed to a ntfs stream which in turn ensured that 'base_path' from the smb_fname was used (which points to the base file). Now we get a pathref fsp (pointing to the base file) instead Signed-off-by: Noel Power Reviewed-by: Jeremy Allison --- source3/smbd/trans2.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 8cdd448a66b..8c973591930 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -681,6 +681,7 @@ static unsigned int estimate_ea_size(connection_struct *conn, files_struct *fsp, size_t total_ea_len = 0; TALLOC_CTX *mem_ctx; struct ea_list *ea_list = NULL; + NTSTATUS status; if (!lp_ea_support(SNUM(conn))) { return 0; @@ -692,16 +693,34 @@ static unsigned int estimate_ea_size(connection_struct *conn, files_struct *fsp, * (streams cannot have EAs), but the estimate isn't just 0 in * this case! */ if (is_ntfs_stream_smb_fname(smb_fname)) { - fsp = NULL; - } - (void)get_ea_list_from_file_path(mem_ctx, + struct smb_filename *pathref = NULL; + status = synthetic_pathref(mem_ctx, + conn->cwd_fsp, + smb_fname->base_name, + NULL, + NULL, + smb_fname->twrp, + smb_fname->flags, + &pathref); + if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(mem_ctx); + return 0; + } + (void)get_ea_list_from_file_path(mem_ctx, conn, - fsp, + pathref->fsp, + pathref, + &total_ea_len, + &ea_list); + } else { + (void)get_ea_list_from_file_path(mem_ctx, + conn, + smb_fname->fsp, smb_fname, &total_ea_len, &ea_list); + } if(conn->sconn->using_smb2) { - NTSTATUS status; unsigned int ret_data_size; /* * We're going to be using fill_ea_chained_buffer() to -- 2.47.3