aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2025-04-08 12:14:29 +0200
committerPádraig Brady <P@draigBrady.com>2025-04-08 12:02:13 +0100
commit0954e91fcff2bd224dc14c9b22bf221fe88b078c (patch)
tree199e5dec0bc1497d6accb0a687d521aae2585764
parentbuild: use _GL_ATTRIBUTE_NONSTRING attribute to avoid new warnings (diff)
downloadcoreutils-0954e91fcff2bd224dc14c9b22bf221fe88b078c.tar.gz
coreutils-0954e91fcff2bd224dc14c9b22bf221fe88b078c.zip
ls: fix crash of "ls -Z ." on OpenBSD's /dev/wd0a disk
* src/ls.c (file_has_aclinfo_cache): Add new static variable 'unsupported_cached'. Don't assume that device 0 never occurs.
-rw-r--r--src/ls.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/ls.c b/src/ls.c
index 6690f7747..de5a1ae2b 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -3309,12 +3309,13 @@ file_has_aclinfo_cache (char const *file, struct fileinfo *f,
{
/* st_dev and associated info for the most recently processed device
for which file_has_aclinfo failed indicating lack of support. */
+ static bool unsupported_cached /* = false */;
static int unsupported_return;
static char *unsupported_scontext;
static int unsupported_scontext_err;
static dev_t unsupported_device;
- if (f->stat_ok && f->stat.st_dev == unsupported_device)
+ if (f->stat_ok && unsupported_cached && f->stat.st_dev == unsupported_device)
{
ai->buf = ai->u.__gl_acl_ch;
ai->size = 0;
@@ -3330,6 +3331,7 @@ file_has_aclinfo_cache (char const *file, struct fileinfo *f,
if (f->stat_ok && n <= 0 && !acl_errno_valid (err)
&& (!(flags & ACL_GET_SCONTEXT) || !acl_errno_valid (ai->scontext_err)))
{
+ unsupported_cached = true;
unsupported_return = n;
unsupported_scontext = ai->scontext;
unsupported_scontext_err = ai->scontext_err;