s3: smbd: Skip calling SMB_VFS_FREADDIR_ATTR() for symlinks
authorSamuel Cabrero <scabrero@samba.org>
Thu, 13 May 2021 15:01:47 +0000 (17:01 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 14 May 2021 20:04:28 +0000 (20:04 +0000)
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
source3/smbd/trans2.c

index 7977468bd9552c92038326f039884bf2f97446e4..2777124c8c6f429b48a1378de13152e2a4b2f418 100644 (file)
@@ -1784,12 +1784,20 @@ static NTSTATUS smbd_marshall_dir_entry(TALLOC_CTX *ctx,
        }
        allocation_size = SMB_VFS_GET_ALLOC_SIZE(conn, NULL, &smb_fname->st);
 
-       status = SMB_VFS_FREADDIR_ATTR(smb_fname->fsp,
-                                      ctx,
-                                      &readdir_attr_data);
-       if (!NT_STATUS_IS_OK(status)) {
-               if (!NT_STATUS_EQUAL(NT_STATUS_NOT_SUPPORTED, status)) {
-                       return status;
+       /*
+        * Skip SMB_VFS_FREADDIR_ATTR if the directory entry is a symlink or
+        * a DFS symlink.
+        */
+       if (smb_fname->fsp != NULL &&
+           !(mode & FILE_ATTRIBUTE_REPARSE_POINT)) {
+               status = SMB_VFS_FREADDIR_ATTR(smb_fname->fsp,
+                                              ctx,
+                                              &readdir_attr_data);
+               if (!NT_STATUS_IS_OK(status)) {
+                       if (!NT_STATUS_EQUAL(NT_STATUS_NOT_SUPPORTED,
+                                            status)) {
+                               return status;
+                       }
                }
        }