From 4d72ebb821518c25e4759ad697d5e18257f80765 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 24 Aug 2018 13:37:27 -0700 Subject: s3: VFS: vfs_full_audit: Ensure smb_fname_str_do_log() only returns absolute pathnames. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13565 Signed-off-by: Jeremy Allison Reviewed-by: Andreas Schneider Autobuild-User(master): Andreas Schneider Autobuild-Date(master): Mon Aug 27 20:23:55 CEST 2018 on sn-devel-144 --- source3/modules/vfs_full_audit.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index b7929605bfa..e7ca89f9fbe 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -667,6 +667,32 @@ static const char *smb_fname_str_do_log(const struct smb_filename *cwd, if (smb_fname == NULL) { return ""; } + + if (smb_fname->base_name[0] != '/') { + char *abs_name = NULL; + struct smb_filename *fname_copy = cp_smb_filename( + do_log_ctx(), + smb_fname); + if (fname_copy == NULL) { + return ""; + } + + if (!ISDOT(smb_fname->base_name)) { + abs_name = talloc_asprintf(do_log_ctx(), + "%s/%s", + cwd->base_name, + smb_fname->base_name); + } else { + abs_name = talloc_strdup(do_log_ctx(), + cwd->base_name); + } + if (abs_name == NULL) { + return ""; + } + fname_copy->base_name = abs_name; + smb_fname = fname_copy; + } + status = get_full_smb_filename(do_log_ctx(), smb_fname, &fname); if (!NT_STATUS_IS_OK(status)) { return ""; -- cgit v1.2.1