s3: VFS: time_audit: Fix smb_time_audit_readlinkat() to cope with real directory...
authorJeremy Allison <jra@samba.org>
Thu, 11 Feb 2021 19:49:24 +0000 (11:49 -0800)
committerJeremy Allison <jra@samba.org>
Sat, 13 Feb 2021 00:17:31 +0000 (00:17 +0000)
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
source3/modules/vfs_time_audit.c

index db9e9d3cf1208ebe38862fd3b95abc320cb2f277..4e2aa404fa9d0df3f862f7f9ac1caf4a45ffed7a 100644 (file)
@@ -1469,10 +1469,19 @@ static int smb_time_audit_readlinkat(vfs_handle_struct *handle,
                                char *buf,
                                size_t bufsiz)
 {
+       struct smb_filename *full_fname = NULL;
        int result;
        struct timespec ts1,ts2;
        double timediff;
 
+       full_fname = full_path_from_dirfsp_atname(talloc_tos(),
+                                               dirfsp,
+                                               smb_fname);
+       if (full_fname == NULL) {
+               errno = ENOMEM;
+               return -1;
+       }
+
        clock_gettime_mono(&ts1);
        result = SMB_VFS_NEXT_READLINKAT(handle,
                                dirfsp,
@@ -1484,9 +1493,10 @@ static int smb_time_audit_readlinkat(vfs_handle_struct *handle,
 
        if (timediff > audit_timeout) {
                smb_time_audit_log_fname("readlinkat", timediff,
-                               smb_fname->base_name);
+                               full_fname->base_name);
        }
 
+       TALLOC_FREE(full_fname);
        return result;
 }