diff options
author | Rob Landley <rob@landley.net> | 2019-11-23 05:08:57 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2019-11-23 05:08:57 -0600 |
commit | 0bee51bc51f08c94ff5714249662c10c8c859b87 (patch) | |
tree | 41e138931ac9c829bd956c1171b954b021453109 | |
parent | 13e973c6134a2e169be870189102d1d0c5654952 (diff) | |
download | toybox-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)
-rw-r--r-- | lib/dirtree.c | 5 |
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; } |