s3: smbd: Protect dos_mode_at_send() from running into a symlink.
authorJeremy Allison <jra@samba.org>
Thu, 10 Jun 2021 17:30:17 +0000 (10:30 -0700)
committerNoel Power <npower@samba.org>
Fri, 11 Jun 2021 09:30:53 +0000 (09:30 +0000)
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power<npower@samba.org>
source3/smbd/dosmode.c

index c4c8be0b72204e948fda9aa61ad5a266adc7cd05..84ee8994a9891d88952f7d1785450103a06b5c52 100644 (file)
@@ -817,6 +817,20 @@ struct tevent_req *dos_mode_at_send(TALLOC_CTX *mem_ctx,
                return tevent_req_post(req, ev);
        }
 
+       if (smb_fname->fsp == NULL) {
+               /*
+                * The pathological case where a caller does
+                * dos_mode_at_send() and smb_fname points at a
+                * symlink in POSIX context. smb_fname->fsp is NULL.
+                *
+                * FIXME ? Should we move to returning
+                * FILE_ATTRIBUTE_REPARSE_POINT here ?
+                */
+               state->dosmode = FILE_ATTRIBUTE_NORMAL;
+               tevent_req_done(req);
+               return tevent_req_post(req, ev);
+       }
+
        subreq = SMB_VFS_GET_DOS_ATTRIBUTES_SEND(state,
                                                 ev,
                                                 dir_fsp,