From 48367c1a0856e8d96f0c9ef073590c5500b71aec Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Sat, 21 Dec 2019 02:09:56 -0600 Subject: renameat: ensure equality test doesn't affect symlinks renameat(2) is supposed to ignore if old or new is a hardlink to the other. However, the way this is written, it also ignores if old or new are symlinks to one another. This is incorrect. --- src/unistd/renameat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unistd/renameat.c b/src/unistd/renameat.c index e2f03d39..6af5aed6 100644 --- a/src/unistd/renameat.c +++ b/src/unistd/renameat.c @@ -48,8 +48,8 @@ int renameat(int oldfd, const char *old, int newfd, const char *new) /* Test equality of old and new. If they both resolve to the same dentry, we do nothing. */ - if (fstatat(oldfd, old, &oldstat, 0) == 0 && \ - fstatat(newfd, new, &newstat, 0) == 0 && \ + if (fstatat(oldfd, old, &oldstat, AT_SYMLINK_NOFOLLOW) == 0 && \ + fstatat(newfd, new, &newstat, AT_SYMLINK_NOFOLLOW) == 0 && \ oldstat.st_dev == newstat.st_dev && \ oldstat.st_ino == newstat.st_ino) return 0; -- cgit v1.2.3-60-g2f50