#include <errno.h>
#include <flexmember.h>
#include <hash.h>
+#include <issymlink.h>
#include <priv-set.h>
#include <root-uid.h>
#include <same-inode.h>
static bool
is_directory_link (char const *file_name, struct stat *st)
{
- char buf[1];
- return (0 <= readlinkat (chdir_fd, file_name, buf, sizeof buf)
+ return (issymlinkat (chdir_fd, file_name)
&& fstatat (chdir_fd, file_name, st, 0) == 0
&& S_ISDIR (st->st_mode));
}
separately. There's a race condition, but that cannot be avoided
on hosts lacking O_NOFOLLOW. */
if (! HAVE_WORKING_O_NOFOLLOW
- && overwriting_old_files && ! dereference_option)
+ && overwriting_old_files && ! dereference_option
+ && issymlinkat (chdir_fd, file_name))
{
- char buf[1];
- if (0 <= readlinkat (chdir_fd, file_name, buf, sizeof buf))
- {
- errno = ELOOP;
- return -1;
- }
+ errno = ELOOP;
+ return -1;
}
fd = openat (chdir_fd, file_name, openflag, mode);