aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2019-11-23 05:08:57 -0600
committerRob Landley <rob@landley.net>2019-11-23 05:08:57 -0600
commit0bee51bc51f08c94ff5714249662c10c8c859b87 (patch)
tree41e138931ac9c829bd956c1171b954b021453109 /lib
parent13e973c6134a2e169be870189102d1d0c5654952 (diff)
downloadtoybox-0bee51bc51f08c94ff5714249662c10c8c859b87.tar.gz
Elliott pointed out a codepath that could use uninitialized data.
(If DIRTREE_SYMFOLLOW returns ENOENT, skipping the second fstatat() would also skip the else goto error)
Diffstat (limited to 'lib')
-rw-r--r--lib/dirtree.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/dirtree.c b/lib/dirtree.c
index beaafd59..9917a815 100644
--- a/lib/dirtree.c
+++ b/lib/dirtree.c
@@ -38,9 +38,8 @@ struct dirtree *dirtree_add_node(struct dirtree *parent, char *name, int flags)
// stat dangling symlinks
if (fstatat(fd, name, &st, sym)) {
- if (errno != ENOENT
- || (!sym && fstatat(fd, name, &st, AT_SYMLINK_NOFOLLOW)))
- {
+ // If we got ENOENT without NOFOLLOW, try again with NOFOLLOW.
+ if (errno!=ENOENT || sym || fstatat(fd, name, &st, AT_SYMLINK_NOFOLLOW)) {
if (flags&DIRTREE_STATLESS) statless++;
else goto error;
}