Commit f9812a51 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.
parent bd19904c
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <errno.h>
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
# include <unistd.h> # include <unistd.h>
# include <fcntl.h> # include <fcntl.h>
...@@ -324,22 +325,18 @@ block_t *DirBlock (access_t *p_access) ...@@ -324,22 +325,18 @@ block_t *DirBlock (access_t *p_access)
{ {
DIR *handle; DIR *handle;
#ifdef HAVE_OPENAT #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) 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 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) || has_inode_loop (current, st.st_dev, st.st_ino)
|| (handle = fdopendir (fd)) == NULL) || (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