summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJody Frankowski <jody.frankowski@gmail.com>2024-10-31 13:13:20 +0100
committerTavian Barnes <tavianator@tavianator.com>2024-10-31 10:19:05 -0400
commit7152645618fc22766f5c954d12e9489866633e26 (patch)
tree04e9063206c54d9cad005903a5efbfe279a6826f /src
parent515cda3e3763484af448ad1bc599d583eeeadb18 (diff)
downloadbfs-7152645618fc22766f5c954d12e9489866633e26.tar.xz
color: Handle bfs_check_capabilities error code (-1) in cpath_has_capabilities
On non-Linux systems, bfs_check_capabilities always returned -1, so cpath_has_capabilities would always return true. If bfs was called with an LS_COLORS containing the `ca` statement, e.g. `ca=30;41`, bfs would color ALL the files. While including the `ca` statement in LS_COLORS on non-Linux systems is unusual, this is not an error and is a valid use-case (e.g. Using GNU ls or lsd). Fixes: 1520d4d3 ("color: Don't color files like directories on ENOTDIR")
Diffstat (limited to 'src')
-rw-r--r--src/color.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/color.c b/src/color.c
index 036dda5..e7f0973 100644
--- a/src/color.c
+++ b/src/color.c
@@ -939,7 +939,7 @@ static const struct bfs_stat *cpath_stat(const struct cpath *cpath) {
/** Check if a path has non-trivial capabilities. */
static bool cpath_has_capabilities(const struct cpath *cpath) {
if (cpath->valid == cpath->len) {
- return bfs_check_capabilities(cpath->ftwbuf);
+ return bfs_check_capabilities(cpath->ftwbuf) > 0;
} else {
// TODO: implement capability checks for arbitrary paths
return false;