2020-12-02 Paul Eggert <eggert@cs.ucla.edu>
+ canonicalize: fix most of another EOVERFLOW issue
+ * lib/canonicalize.c (canonicalize_filename_mode):
+ Do not call stat if fewer than 20 symlinks have been traversed.
+ This avoids EOVERFLOW failure in the common case where there
+ are not that many symlinks, while continuing to catch loops
+ (or fail due to EOVERFLOW) in the unusual case when there
+ are many symlinks to traverse.
+
canonicalize: do not assume symlinks have st_ino
* lib/canonicalize.c (canonicalize_filename_mode):
When checking for loops, use st_dev and st_ino from the parent
int saved_errno;
int can_flags = can_mode & ~CAN_MODE_MASK;
bool logical = can_flags & CAN_NOLINKS;
+ int num_links = 0;
size_t prefix_len;
can_mode &= CAN_MODE_MASK;
{
/* A physical traversal and RNAME is a symbolic link. */
- if (*start)
+ if (num_links < 20)
+ num_links++;
+ else if (*start)
{
- /* Get the device and inode of the parent directory, as
+ /* Enough symlinks have been seen that it is time to
+ worry about being in a symlink cycle.
+ Get the device and inode of the parent directory, as
pre-2017 POSIX says this info is not reliable for
symlinks. */
dest[- (end - start)] = '\0';