From 4b86f6cb6e1bd5560dc8c6ab067a0e8d59d051d7 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 8 Sep 2017 15:28:39 -0700 Subject: [PATCH] s3: vfs: catia: compression get/set must act only on base file, and must cope with fsp==NULL. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Correctly do filename conversion. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13003 Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme Autobuild-User(master): Ralph Böhme Autobuild-Date(master): Tue Sep 12 10:50:57 CEST 2017 on sn-devel-144 (cherry picked from commit 3ff1b83ab7cb3a6ab94b87d0bf73857b731c869d) --- source3/modules/vfs_catia.c | 44 ++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/source3/modules/vfs_catia.c b/source3/modules/vfs_catia.c index c6d8f584b5f..65b3614391d 100644 --- a/source3/modules/vfs_catia.c +++ b/source3/modules/vfs_catia.c @@ -2246,16 +2246,48 @@ static NTSTATUS catia_get_compression(vfs_handle_struct *handle, NTSTATUS result; struct catia_cache *cc = NULL; int ret; + struct smb_filename *mapped_smb_fname = NULL; + char *mapped_name = NULL; - ret = CATIA_FETCH_FSP_PRE_NEXT(talloc_tos(), handle, fsp, &cc); - if (ret != 0) { - return map_nt_error_from_unix(errno); + if (fsp != NULL) { + ret = CATIA_FETCH_FSP_PRE_NEXT(talloc_tos(), handle, fsp, &cc); + if (ret != 0) { + return map_nt_error_from_unix(errno); + } + mapped_smb_fname = fsp->fsp_name; + } else { + result = catia_string_replace_allocate(handle->conn, + smb_fname->base_name, + &mapped_name, + vfs_translate_to_unix); + if (!NT_STATUS_IS_OK(result)) { + return result; + } + + mapped_smb_fname = synthetic_smb_fname(talloc_tos(), + mapped_name, + NULL, + NULL, + smb_fname->flags); + if (mapped_smb_fname == NULL) { + TALLOC_FREE(mapped_name); + return NT_STATUS_NO_MEMORY; + } + + TALLOC_FREE(mapped_name); } - result = SMB_VFS_NEXT_GET_COMPRESSION(handle, mem_ctx, fsp, smb_fname, - _compression_fmt); + result = SMB_VFS_NEXT_GET_COMPRESSION(handle, + mem_ctx, + fsp, + mapped_smb_fname, + _compression_fmt); - CATIA_FETCH_FSP_POST_NEXT(&cc, fsp); + if (fsp != NULL) { + CATIA_FETCH_FSP_POST_NEXT(&cc, fsp); + } else { + TALLOC_FREE(mapped_smb_fname); + } return result; } -- 2.47.2