From: Volker Lendecke Date: Sat, 8 Nov 2025 09:37:55 +0000 (+0100) Subject: lib: Introduce cp_smb_basename() helper function X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0835fe53cc719a249a86319faabefd413d91d861;p=thirdparty%2Fsamba.git lib: Introduce cp_smb_basename() helper function I always had to look up the sequence of NULLs and 0s. Save lines. Signed-off-by: Volker Lendecke Reviewed-by: Anoop C S Autobuild-User(master): Volker Lendecke Autobuild-Date(master): Mon Nov 10 14:33:28 UTC 2025 on atb-devel-224 --- diff --git a/source3/include/proto.h b/source3/include/proto.h index f773d70b7c4..8f4f500ded5 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -710,6 +710,7 @@ struct smb_filename *cp_smb_filename(TALLOC_CTX *mem_ctx, const struct smb_filename *in); struct smb_filename *cp_smb_filename_nostream(TALLOC_CTX *mem_ctx, const struct smb_filename *in); +struct smb_filename *cp_smb_basename(TALLOC_CTX *mem_ctx, const char *fname); bool is_ntfs_stream_smb_fname(const struct smb_filename *smb_fname); bool is_ntfs_default_stream_smb_fname(const struct smb_filename *smb_fname); bool is_named_stream(const struct smb_filename *smb_fname); diff --git a/source3/lib/filename_util.c b/source3/lib/filename_util.c index 0108ae6e6a0..fc821088862 100644 --- a/source3/lib/filename_util.c +++ b/source3/lib/filename_util.c @@ -74,6 +74,11 @@ struct smb_filename *synthetic_smb_fname(TALLOC_CTX *mem_ctx, return cp_smb_filename(mem_ctx, &smb_fname_loc); } +struct smb_filename *cp_smb_basename(TALLOC_CTX *mem_ctx, const char *fname) +{ + return synthetic_smb_fname(mem_ctx, fname, NULL, NULL, 0, 0); +} + /** * Utility function used by VFS calls that must *NOT* operate * on a stream filename, only the base_name. diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c index be7b4c515e4..dc10a516ff5 100644 --- a/source3/modules/vfs_ceph.c +++ b/source3/modules/vfs_ceph.c @@ -1126,7 +1126,7 @@ static struct smb_filename *cephwrap_getwd(struct vfs_handle_struct *handle, { const char *cwd = ceph_getcwd(handle->data); DBG_DEBUG("[CEPH] getwd(%p) = %s\n", handle, cwd); - return synthetic_smb_fname(ctx, cwd, NULL, NULL, 0, 0); + return cp_smb_basename(ctx, cwd); } static int strict_allocate_ftruncate(struct vfs_handle_struct *handle, @@ -1408,7 +1408,7 @@ static struct smb_filename *cephwrap_realpath(struct vfs_handle_struct *handle, } DBG_DEBUG("[CEPH] realpath(%p, %s) = %s\n", handle, path, result); - result_fname = synthetic_smb_fname(ctx, result, NULL, NULL, 0, 0); + result_fname = cp_smb_basename(ctx, result); TALLOC_FREE(result); return result_fname; } diff --git a/source3/modules/vfs_ceph_new.c b/source3/modules/vfs_ceph_new.c index e6fa0449d47..5dfdea583e9 100644 --- a/source3/modules/vfs_ceph_new.c +++ b/source3/modules/vfs_ceph_new.c @@ -3436,7 +3436,7 @@ static struct smb_filename *vfs_ceph_getwd(struct vfs_handle_struct *handle, cwd = config->ceph_getcwd_fn(config->mount); DBG_DEBUG("[CEPH] getwd: handle=%p cwd=%s\n", handle, cwd); END_PROFILE_X(syscall_getwd); - return synthetic_smb_fname(ctx, cwd, NULL, NULL, 0, 0); + return cp_smb_basename(ctx, cwd); } static int strict_allocate_ftruncate(struct vfs_handle_struct *handle, @@ -3816,7 +3816,7 @@ static struct smb_filename *vfs_ceph_realpath(struct vfs_handle_struct *handle, } DBG_DEBUG("[CEPH] realpath(%p, %s) = %s\n", handle, path, result); - result_fname = synthetic_smb_fname(ctx, result, NULL, NULL, 0, 0); + result_fname = cp_smb_basename(ctx, result); TALLOC_FREE(result); out: END_PROFILE_X(syscall_realpath); diff --git a/source3/modules/vfs_ceph_snapshots.c b/source3/modules/vfs_ceph_snapshots.c index e6d097ad5de..46d45c84dc6 100644 --- a/source3/modules/vfs_ceph_snapshots.c +++ b/source3/modules/vfs_ceph_snapshots.c @@ -151,12 +151,7 @@ static int ceph_snap_fill_label(struct vfs_handle_struct *handle, return -EINVAL; } - smb_fname = synthetic_smb_fname(tmp_ctx, - snap_path, - NULL, - NULL, - 0, - 0); + smb_fname = cp_smb_basename(tmp_ctx, snap_path); if (smb_fname == NULL) { return -ENOMEM; } @@ -605,12 +600,7 @@ static int ceph_snap_gmt_convert_dir(struct vfs_handle_struct *handle, goto err_out; } - smb_fname = synthetic_smb_fname(tmp_ctx, - _converted_buf, - NULL, - NULL, - 0, - 0); + smb_fname = cp_smb_basename(tmp_ctx, _converted_buf); if (smb_fname == NULL) { ret = -ENOMEM; goto err_out; diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 3b2463876da..34b00f5b547 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -2840,12 +2840,7 @@ static struct smb_filename *vfswrap_getwd(vfs_handle_struct *handle, if (result == NULL) { return NULL; } - smb_fname = synthetic_smb_fname(ctx, - result, - NULL, - NULL, - 0, - 0); + smb_fname = cp_smb_basename(ctx, result); /* * sys_getwd() *always* returns malloced memory. * We must free here to avoid leaks: @@ -3307,12 +3302,7 @@ static struct smb_filename *vfswrap_realpath(vfs_handle_struct *handle, result = sys_realpath(smb_fname->base_name); END_PROFILE_X(syscall_realpath); if (result) { - result_fname = synthetic_smb_fname(ctx, - result, - NULL, - NULL, - 0, - 0); + result_fname = cp_smb_basename(ctx, result); SAFE_FREE(result); } return result_fname; diff --git a/source3/modules/vfs_fileid.c b/source3/modules/vfs_fileid.c index f76899e37e4..5ba33039a6e 100644 --- a/source3/modules/vfs_fileid.c +++ b/source3/modules/vfs_fileid.c @@ -432,15 +432,11 @@ static int get_connectpath_ino(struct vfs_handle_struct *handle, } } - fname = synthetic_smb_fname(frame, - fullpath, - NULL, - NULL, - 0, - 0); + fname = cp_smb_basename(frame, fullpath); if (fname == NULL) { - DBG_ERR("synthetic_smb_fname(%s) failed - %s\n", - fullpath, strerror(errno)); + DBG_ERR("cp_smb_basename(%s) failed - %s\n", + fullpath, + strerror(errno)); TALLOC_FREE(frame); return -1; } diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index 2ae3fdb94a6..9a634bab758 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -5151,12 +5151,7 @@ static bool fruit_get_bandsize(vfs_handle_struct *handle, goto out; } - smb_fname = synthetic_smb_fname(talloc_tos(), - plist, - NULL, - NULL, - 0, - 0); + smb_fname = cp_smb_basename(talloc_tos(), plist); if (smb_fname == NULL) { ok = false; goto out; @@ -5290,12 +5285,7 @@ static bool fruit_get_num_bands(vfs_handle_struct *handle, return false; } - bands_dir = synthetic_smb_fname(talloc_tos(), - path, - NULL, - NULL, - 0, - 0); + bands_dir = cp_smb_basename(talloc_tos(), path); TALLOC_FREE(path); if (bands_dir == NULL) { return false; diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c index 0fabb9a7e08..6fe12985d9c 100644 --- a/source3/modules/vfs_glusterfs.c +++ b/source3/modules/vfs_glusterfs.c @@ -1700,12 +1700,7 @@ static struct smb_filename *vfs_gluster_getwd(struct vfs_handle_struct *handle, if (ret == NULL) { return NULL; } - smb_fname = synthetic_smb_fname(ctx, - ret, - NULL, - NULL, - 0, - 0); + smb_fname = cp_smb_basename(ctx, ret); return smb_fname; } @@ -1854,12 +1849,7 @@ static struct smb_filename *vfs_gluster_realpath(struct vfs_handle_struct *handl smb_fname->base_name, resolved_path); if (result != NULL) { - result_fname = synthetic_smb_fname(ctx, - result, - NULL, - NULL, - 0, - 0); + result_fname = cp_smb_basename(ctx, result); } SAFE_FREE(resolved_path); diff --git a/source3/modules/vfs_recycle.c b/source3/modules/vfs_recycle.c index 421659fa6ab..bfea7ef75f4 100644 --- a/source3/modules/vfs_recycle.c +++ b/source3/modules/vfs_recycle.c @@ -311,12 +311,7 @@ static bool recycle_create_dir(vfs_handle_struct *handle, DEBUG(5, ("recycle: creating new dir %s\n", new_dir)); - smb_fname = synthetic_smb_fname(talloc_tos(), - new_dir, - NULL, - NULL, - 0, - 0); + smb_fname = cp_smb_basename(talloc_tos(), new_dir); if (smb_fname == NULL) { goto done; } diff --git a/source3/modules/vfs_shadow_copy.c b/source3/modules/vfs_shadow_copy.c index 87fc191904c..e798d7692dc 100644 --- a/source3/modules/vfs_shadow_copy.c +++ b/source3/modules/vfs_shadow_copy.c @@ -162,12 +162,8 @@ static int shadow_copy_get_shadow_copy_data(vfs_handle_struct *handle, const char *dname = NULL; char *talloced = NULL; NTSTATUS status; - struct smb_filename *smb_fname = synthetic_smb_fname(talloc_tos(), - fsp->conn->connectpath, - NULL, - NULL, - 0, - 0); + struct smb_filename *smb_fname = cp_smb_basename( + talloc_tos(), fsp->conn->connectpath); if (smb_fname == NULL) { errno = ENOMEM; return -1; diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c index ba9d01372c0..17e2b84d7bd 100644 --- a/source3/modules/vfs_shadow_copy2.c +++ b/source3/modules/vfs_shadow_copy2.c @@ -730,12 +730,7 @@ static char *shadow_copy2_find_mount_point(TALLOC_CTX *mem_ctx, dev_t dev; char *p; - smb_fname_cpath = synthetic_smb_fname(mem_ctx, - handle->conn->connectpath, - NULL, - NULL, - 0, - 0); + smb_fname_cpath = cp_smb_basename(mem_ctx, handle->conn->connectpath); if (smb_fname_cpath == NULL) { errno = ENOMEM; return NULL; diff --git a/source3/modules/vfs_virusfilter.c b/source3/modules/vfs_virusfilter.c index 3d78d22c01a..a6e167df126 100644 --- a/source3/modules/vfs_virusfilter.c +++ b/source3/modules/vfs_virusfilter.c @@ -155,12 +155,7 @@ static bool quarantine_create_dir( DBG_INFO("quarantine: creating new dir %s\n", new_dir); - smb_fname = synthetic_smb_fname(talloc_tos(), - new_dir, - NULL, - NULL, - 0, - 0); + smb_fname = cp_smb_basename(talloc_tos(), new_dir); if (smb_fname == NULL) { goto done; } diff --git a/source3/modules/vfs_widelinks.c b/source3/modules/vfs_widelinks.c index df00d72707d..9b802048dbe 100644 --- a/source3/modules/vfs_widelinks.c +++ b/source3/modules/vfs_widelinks.c @@ -236,12 +236,7 @@ static struct smb_filename *widelinks_getwd(vfs_handle_struct *handle, /* getwd before chdir. See note 1b above. */ return SMB_VFS_NEXT_GETWD(handle, ctx); } - return synthetic_smb_fname(ctx, - config->cwd, - NULL, - NULL, - 0, - 0); + return cp_smb_basename(ctx, config->cwd); } static struct smb_filename *widelinks_realpath(vfs_handle_struct *handle, @@ -297,12 +292,7 @@ static struct smb_filename *widelinks_realpath(vfs_handle_struct *handle, pathname, resolved_pathname); - smb_fname = synthetic_smb_fname(ctx, - resolved_pathname, - NULL, - NULL, - 0, - 0); + smb_fname = cp_smb_basename(ctx, resolved_pathname); TALLOC_FREE(pathname); TALLOC_FREE(resolved_pathname); return smb_fname; diff --git a/source3/modules/vfs_xattr_tdb.c b/source3/modules/vfs_xattr_tdb.c index 19331d0de4f..5a2d10341c6 100644 --- a/source3/modules/vfs_xattr_tdb.c +++ b/source3/modules/vfs_xattr_tdb.c @@ -52,12 +52,7 @@ static int xattr_tdb_get_file_id(struct vfs_handle_struct *handle, TALLOC_CTX *frame = talloc_stackframe(); struct smb_filename *smb_fname; - smb_fname = synthetic_smb_fname(frame, - path, - NULL, - NULL, - 0, - 0); + smb_fname = cp_smb_basename(frame, path); if (smb_fname == NULL) { TALLOC_FREE(frame); errno = ENOMEM; diff --git a/source3/printing/printspoolss.c b/source3/printing/printspoolss.c index 94404f7682a..60a53571a65 100644 --- a/source3/printing/printspoolss.c +++ b/source3/printing/printspoolss.c @@ -215,12 +215,7 @@ NTSTATUS print_spool_open(files_struct *fsp, } /* setup a full fsp */ - fsp->fsp_name = synthetic_smb_fname(fsp, - pf->filename, - NULL, - NULL, - 0, - 0); + fsp->fsp_name = cp_smb_basename(fsp, pf->filename); if (fsp->fsp_name == NULL) { status = NT_STATUS_NO_MEMORY; goto done; diff --git a/source3/rpc_server/fss/srv_fss_agent.c b/source3/rpc_server/fss/srv_fss_agent.c index 4de600fd06c..583814822bb 100644 --- a/source3/rpc_server/fss/srv_fss_agent.c +++ b/source3/rpc_server/fss/srv_fss_agent.c @@ -173,12 +173,7 @@ static bool snap_path_exists(TALLOC_CTX *ctx, struct messaging_context *msg_ctx, goto out; } - smb_fname = synthetic_smb_fname(service, - sc->sc_path, - NULL, - NULL, - 0, - 0); + smb_fname = cp_smb_basename(service, sc->sc_path); if (smb_fname == NULL) { goto out; } diff --git a/source3/smbd/conn.c b/source3/smbd/conn.c index 40a9fc482e1..f1c75e29205 100644 --- a/source3/smbd/conn.c +++ b/source3/smbd/conn.c @@ -114,12 +114,7 @@ connection_struct *conn_new(struct smbd_server_connection *sconn) if (conn->cwd_fsp == NULL) { goto nomem; } - conn->cwd_fsp->fsp_name = synthetic_smb_fname(conn->cwd_fsp, - ".", - NULL, - NULL, - 0, - 0); + conn->cwd_fsp->fsp_name = cp_smb_basename(conn->cwd_fsp, "."); if (conn->cwd_fsp->fsp_name == NULL) { goto nomem; } diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c index c00fed20795..b80579c8e55 100644 --- a/source3/smbd/dir.c +++ b/source3/smbd/dir.c @@ -1215,12 +1215,7 @@ const char *ReadDirName(struct smb_Dir *dir_hnd, char **ptalloced) struct smb_filename *atname = NULL; int ret; - atname = synthetic_smb_fname(talloc_tos(), - n, - NULL, - NULL, - 0, - 0); + atname = cp_smb_basename(talloc_tos(), n); if (atname == NULL) { TALLOC_FREE(talloced); continue; diff --git a/source3/smbd/files.c b/source3/smbd/files.c index 7cb7ecfa965..209c7fcf2b4 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -170,12 +170,7 @@ NTSTATUS file_new(struct smb_request *req, connection_struct *conn, * few NULL checks, so make sure it's initialized with something. to * be safe until an audit can be done. */ - fsp->fsp_name = synthetic_smb_fname(fsp, - "", - NULL, - NULL, - 0, - 0); + fsp->fsp_name = cp_smb_basename(fsp, ""); if (fsp->fsp_name == NULL) { file_free(NULL, fsp); return NT_STATUS_NO_MEMORY; diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c index eb0333d46be..05cc1181645 100644 --- a/source3/smbd/msdfs.c +++ b/source3/smbd/msdfs.c @@ -1345,12 +1345,7 @@ bool create_msdfs_link(const struct junction_map *jucn, goto out; } - smb_fname = synthetic_smb_fname(frame, - path, - NULL, - NULL, - 0, - 0); + smb_fname = cp_smb_basename(frame, path); if (smb_fname == NULL) { goto out; } @@ -1431,12 +1426,7 @@ bool remove_msdfs_link(const struct junction_map *jucn, return false; } - smb_fname = synthetic_smb_fname(frame, - path, - NULL, - NULL, - 0, - 0); + smb_fname = cp_smb_basename(frame, path); if (smb_fname == NULL) { TALLOC_FREE(frame); errno = ENOMEM; @@ -1517,12 +1507,7 @@ static size_t count_dfs_links(TALLOC_CTX *ctx, goto out; } - smb_fname = synthetic_smb_fname(frame, - ".", - NULL, - NULL, - 0, - 0); + smb_fname = cp_smb_basename(frame, "."); if (smb_fname == NULL) { goto out; } @@ -1540,13 +1525,7 @@ static size_t count_dfs_links(TALLOC_CTX *ctx, } while ((dname = ReadDirName(dir_hnd, &talloced)) != NULL) { - struct smb_filename *smb_dname = - synthetic_smb_fname(frame, - dname, - NULL, - NULL, - 0, - 0); + struct smb_filename *smb_dname = cp_smb_basename(frame, dname); if (smb_dname == NULL) { goto out; } @@ -1657,12 +1636,7 @@ static int form_junctions(TALLOC_CTX *ctx, goto out; } - smb_fname = synthetic_smb_fname(frame, - ".", - NULL, - NULL, - 0, - 0); + smb_fname = cp_smb_basename(frame, "."); if (smb_fname == NULL) { goto out; } @@ -1688,12 +1662,7 @@ static int form_junctions(TALLOC_CTX *ctx, TALLOC_FREE(talloced); goto out; } - smb_dname = synthetic_smb_fname(talloc_tos(), - dname, - NULL, - NULL, - 0, - 0); + smb_dname = cp_smb_basename(talloc_tos(), dname); if (smb_dname == NULL) { TALLOC_FREE(talloced); goto out; diff --git a/source3/smbd/ntquotas.c b/source3/smbd/ntquotas.c index d3e19490885..affd7d58f81 100644 --- a/source3/smbd/ntquotas.c +++ b/source3/smbd/ntquotas.c @@ -84,12 +84,7 @@ NTSTATUS vfs_get_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype, return NT_STATUS_NO_SUCH_USER; } - smb_fname_cwd = synthetic_smb_fname(talloc_tos(), - ".", - NULL, - NULL, - 0, - 0); + smb_fname_cwd = cp_smb_basename(talloc_tos(), "."); if (smb_fname_cwd == NULL) { return NT_STATUS_NO_MEMORY; } diff --git a/source3/smbd/pysmbd.c b/source3/smbd/pysmbd.c index fe439dfe2c2..5b599d85ef8 100644 --- a/source3/smbd/pysmbd.c +++ b/source3/smbd/pysmbd.c @@ -1158,15 +1158,8 @@ static PyObject *py_smbd_mkdir(PyObject *self, PyObject *args, PyObject *kwargs) return NULL; } - smb_fname = synthetic_smb_fname(talloc_tos(), - canonicalize_path(talloc_tos(), - conn, - fname), - NULL, - NULL, - 0, - 0); - + smb_fname = cp_smb_basename( + talloc_tos(), canonicalize_path(talloc_tos(), conn, fname)); if (smb_fname == NULL) { TALLOC_FREE(frame); return NULL; diff --git a/source3/smbd/smb2_pipes.c b/source3/smbd/smb2_pipes.c index 8f8786752db..ef5acc2c2a8 100644 --- a/source3/smbd/smb2_pipes.c +++ b/source3/smbd/smb2_pipes.c @@ -55,12 +55,7 @@ NTSTATUS open_np_file(struct smb_request *smb_req, const char *name, fsp->fsp_flags.can_lock = false; fsp->access_mask = FILE_READ_DATA | FILE_WRITE_DATA; - smb_fname = synthetic_smb_fname(talloc_tos(), - name, - NULL, - NULL, - 0, - 0); + smb_fname = cp_smb_basename(talloc_tos(), name); if (smb_fname == NULL) { file_free(smb_req, fsp); return NT_STATUS_NO_MEMORY; diff --git a/source3/smbd/smb2_service.c b/source3/smbd/smb2_service.c index 561d6461286..e43c3d9faa2 100644 --- a/source3/smbd/smb2_service.c +++ b/source3/smbd/smb2_service.c @@ -78,12 +78,7 @@ bool set_conn_connectpath(connection_struct *conn, const char *connectpath) * start as conn->connectpath. */ TALLOC_FREE(conn->cwd_fsp->fsp_name); - conn->cwd_fsp->fsp_name = synthetic_smb_fname(conn, - conn->connectpath, - NULL, - NULL, - 0, - 0); + conn->cwd_fsp->fsp_name = cp_smb_basename(conn, conn->connectpath); if (conn->cwd_fsp->fsp_name == NULL) { return false; } diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index da7181db1d7..30cec1ea68f 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -1036,12 +1036,7 @@ struct smb_filename *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn) goto nocache; } - smb_fname_dot = synthetic_smb_fname(ctx, - ".", - NULL, - NULL, - 0, - 0); + smb_fname_dot = cp_smb_basename(ctx, "."); if (smb_fname_dot == NULL) { errno = ENOMEM; goto out; @@ -1296,7 +1291,7 @@ NTSTATUS vfs_at_fspcwd(TALLOC_CTX *mem_ctx, return NT_STATUS_NO_MEMORY; } - fsp->fsp_name = synthetic_smb_fname(fsp, ".", NULL, NULL, 0, 0); + fsp->fsp_name = cp_smb_basename(fsp, "."); if (fsp->fsp_name == NULL) { TALLOC_FREE(fsp); return NT_STATUS_NO_MEMORY; @@ -1326,12 +1321,7 @@ uint32_t vfs_get_fs_capabilities(struct connection_struct *conn, struct vfs_statvfs_struct statbuf = {}; int ret; - smb_fname_cpath = synthetic_smb_fname(talloc_tos(), - conn->connectpath, - NULL, - NULL, - 0, - 0); + smb_fname_cpath = cp_smb_basename(talloc_tos(), conn->connectpath); if (smb_fname_cpath == NULL) { return caps; } diff --git a/source3/utils/net_vfs.c b/source3/utils/net_vfs.c index 8120811676e..0689340b1f3 100644 --- a/source3/utils/net_vfs.c +++ b/source3/utils/net_vfs.c @@ -228,12 +228,7 @@ static int net_vfs_get_ntacl(struct net_context *net, } path = argv[1]; - smb_fname = synthetic_smb_fname(state.mem_ctx, - path, - NULL, - NULL, - 0, - 0); + smb_fname = cp_smb_basename(state.mem_ctx, path); if (smb_fname == NULL) { goto done; } @@ -333,12 +328,7 @@ static bool do_unfruit(const char *path) } } - smb_fname = synthetic_smb_fname(state.mem_ctx, - path, - NULL, - NULL, - 0, - 0); + smb_fname = cp_smb_basename(state.mem_ctx, path); if (smb_fname == NULL) { return false; }