diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-12-21 02:09:56 -0600 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2023-05-05 21:21:41 -0500 |
commit | 48367c1a0856e8d96f0c9ef073590c5500b71aec (patch) | |
tree | f65474ccfacd98fed969be60be2161ef62951aaa /src/unistd | |
parent | dc88f0e0143b6e2f9fffe42f2b221f1e24aa8034 (diff) | |
download | musl-48367c1a0856e8d96f0c9ef073590c5500b71aec.tar.gz musl-48367c1a0856e8d96f0c9ef073590c5500b71aec.tar.bz2 musl-48367c1a0856e8d96f0c9ef073590c5500b71aec.tar.xz musl-48367c1a0856e8d96f0c9ef073590c5500b71aec.zip |
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.
Diffstat (limited to 'src/unistd')
-rw-r--r-- | src/unistd/renameat.c | 4 |
1 files 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; |