From 7152645618fc22766f5c954d12e9489866633e26 Mon Sep 17 00:00:00 2001 From: Jody Frankowski Date: Thu, 31 Oct 2024 13:13:20 +0100 Subject: 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") --- src/color.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') 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; -- cgit v1.2.3