diff options
author | Elliott Hughes <enh@google.com> | 2019-12-13 16:15:26 -0800 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2019-12-14 17:36:43 -0600 |
commit | 08b5330e2bbdfe5b79e7571c3bf242c7befe96bd (patch) | |
tree | 85e5d47cea0be1c41041917d1e63e509d3d4c915 | |
parent | b9e621e86b2b6e40c6d7b83e7fe6cd110433f498 (diff) | |
download | toybox-08b5330e2bbdfe5b79e7571c3bf242c7befe96bd.tar.gz |
dirtree.c: avoid spurious EINVAL warnings.
An Android engineer complained that they were seeing this when not
running as root:
$ adb shell ls
ls: ./postinstall: Invalid argument
ls: ./init: Permission denied
ls: ./data_mirror: Invalid argument
ls: ./init.environ.rc: Invalid argument
ls: ./metadata: Invalid argument
acct
adb_keys
apex
From strace, it was here:
newfstatat(4, "adb_keys", 0x7fc67eca88, AT_SYMLINK_NOFOLLOW) = -1 EACCES (Permission denied)
readlinkat(4, "adb_keys", 0x5e843c7720, 4095) = -1 EINVAL (Invalid argument)
So stop looking at st.st_mode (and then deciding to do a readlinkat())
if we didn't actually successfully stat().
-rw-r--r-- | lib/dirtree.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/dirtree.c b/lib/dirtree.c index 9917a815..f4cc620d 100644 --- a/lib/dirtree.c +++ b/lib/dirtree.c @@ -44,7 +44,7 @@ struct dirtree *dirtree_add_node(struct dirtree *parent, char *name, int flags) else goto error; } } - if (S_ISLNK(st.st_mode)) { + if (!statless && S_ISLNK(st.st_mode)) { if (0>(linklen = readlinkat(fd, name, libbuf, 4095))) goto error; libbuf[linklen++]=0; } |