]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
fts: Don't return FTS_SLNONE if it's not a symlink (if race).
authorjilles <jilles@FreeBSD.org>
Sat, 4 Apr 2015 20:22:12 +0000 (20:22 +0000)
committerjilles <jilles@FreeBSD.org>
Sat, 4 Apr 2015 20:22:12 +0000 (20:22 +0000)
commitbf4374c54589a5e01f37a14c1064beab51743434
tree7b757a26ad5447d761715965487d10dfa6828a78
parent5abd1a7c3183c9dce76d1e6b0b75f8a4a76ffbb2
fts: Don't return FTS_SLNONE if it's not a symlink (if race).

When following symlinks, fts returned FTS_SLNONE when fstatat(flag=0)
failed, but a subsequent fstatat(flag=AT_SYMLINK_NOFOLLOW) succeeded. This
incorrectly triggered if a filename existed to be read from the directory,
was deleted before the fstatat(flag=0) and created again after the
fstatat(flag=0).

Fix this by only returning FTS_SLNONE if the result from
fstatat(flag=AT_SYMLINK_NOFOLLOW) is actually a symlink. If it is not a
symlink, treat it as if fstatat(flag=0) succeeded.

PR: 196724
Reported and tested by: pho
MFC after: 1 week
lib/libc/gen/fts.c