From c0a9c8698c21b72e3409af9263e2afa16443f805 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Tue, 28 Apr 2020 16:00:42 +0200 Subject: [PATCH] smbd: use parent_smb_fname() in unix_convert() Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- source3/smbd/filename.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c index 2c66a80a9c7..a9ccac39956 100644 --- a/source3/smbd/filename.c +++ b/source3/smbd/filename.c @@ -1193,21 +1193,26 @@ NTSTATUS unix_convert(TALLOC_CTX *mem_ctx, * Was it a missing last component ? * or a missing intermediate component ? */ - struct smb_filename parent_fname; - const char *last_component = NULL; - - ZERO_STRUCT(parent_fname); - if (!parent_dirname(state->mem_ctx, state->smb_fname->base_name, - &parent_fname.base_name, - &last_component)) { + struct smb_filename *parent_fname = NULL; + struct smb_filename *base_fname = NULL; + bool ok; + + ok = parent_smb_fname(state->mem_ctx, + state->smb_fname, + &parent_fname, + &base_fname); + if (!ok) { status = NT_STATUS_NO_MEMORY; goto fail; } if (state->posix_pathnames) { - ret = SMB_VFS_LSTAT(state->conn, &parent_fname); + ret = SMB_VFS_LSTAT(state->conn, + parent_fname); } else { - ret = SMB_VFS_STAT(state->conn, &parent_fname); + ret = SMB_VFS_STAT(state->conn, + parent_fname); } + TALLOC_FREE(parent_fname); if (ret == -1) { if (errno == ENOTDIR || errno == ENOENT || -- 2.47.3