Commit d3444915 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

directory: do not get stuck on a FIFO (fix #6940)

Also avoid fstat()+close() on non-directoy files.
(cherry picked from commit f9812a51)

Conflicts:
	modules/access/directory.c
parent da7b4234
......@@ -38,7 +38,7 @@
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#include <errno.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
# include <fcntl.h>
......@@ -309,22 +309,18 @@ block_t *DirBlock (access_t *p_access)
{
DIR *handle;
#ifdef HAVE_OPENAT
int fd = vlc_openat (dirfd (current->handle), entry, O_RDONLY);
int fd = vlc_openat (dirfd (current->handle), entry,
O_RDONLY | O_DIRECTORY);
if (fd == -1)
goto skip; /* File cannot be opened... forget it */
struct stat st;
if (fstat (fd, &st))
{
close (fd);
goto skip; /* cannot stat?! */
}
if (!S_ISDIR (st.st_mode))
{
close (fd);
if (errno == ENOTDIR)
goto notdir;
goto skip; /* File cannot be opened... forget it */
}
if (p_sys->mode == MODE_NONE
struct stat st;
if (fstat (fd, &st)
|| p_sys->mode == MODE_NONE
|| has_inode_loop (current, st.st_dev, st.st_ino)
|| (handle = fdopendir (fd)) == NULL)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment