s3: VFS: vfs_full_audit: Ensure smb_fname_str_do_log() only returns absolute pathnames.
authorJeremy Allison <jra@samba.org>
Fri, 24 Aug 2018 20:37:27 +0000 (13:37 -0700)
committerAndreas Schneider <asn@cryptomilk.org>
Mon, 27 Aug 2018 18:23:55 +0000 (20:23 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13565

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Mon Aug 27 20:23:55 CEST 2018 on sn-devel-144

source3/modules/vfs_full_audit.c

index b7929605bfab77956a30653e09142152af4196e5..e7ca89f9fbe4ddabc3a83b456d9148e9bb1743a1 100644 (file)
@@ -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 "";