Skip to content

Commit b857d66

Browse files
committed
ls: fix aclinfo cache bug
Found when testing on a new platform with a new file system. * src/ls.c (file_has_aclinfo_cache): For failures, also cache return value, scontext, and scontext_err, and when using cached values make sure buf and size have reasonable values for aclinfo_free etc.
1 parent e9d294a commit b857d66

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/ls.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3284,19 +3284,33 @@ static int
32843284
file_has_aclinfo_cache (char const *file, struct fileinfo *f,
32853285
struct aclinfo *ai, int flags)
32863286
{
3287-
/* st_dev of the most recently processed device for which we've
3288-
found that file_has_acl fails indicating lack of support. */
3287+
/* st_dev and associated info for the most recently processed device
3288+
for which file_has_acl failed indicating lack of support. */
3289+
static int unsupported_return;
3290+
static char *unsupported_scontext;
3291+
static int unsupported_scontext_err;
32893292
static dev_t unsupported_device;
32903293

32913294
if (f->stat.st_dev == unsupported_device)
32923295
{
3296+
ai->buf = ai->u.__gl_acl_ch;
3297+
ai->size = 0;
3298+
ai->scontext = unsupported_scontext;
3299+
ai->scontext_err = unsupported_scontext_err;
32933300
errno = ENOTSUP;
3294-
return 0;
3301+
return unsupported_return;
32953302
}
32963303

3304+
errno = 0;
32973305
int n = file_has_aclinfo (file, ai, flags);
3298-
if (n <= 0 && !acl_errno_valid (ai->u.err))
3299-
unsupported_device = f->stat.st_dev;
3306+
int err = errno;
3307+
if (n <= 0 && !acl_errno_valid (err))
3308+
{
3309+
unsupported_return = n;
3310+
unsupported_scontext = ai->scontext;
3311+
unsupported_scontext_err = ai->scontext_err;
3312+
unsupported_device = f->stat.st_dev;
3313+
}
33003314
return n;
33013315
}
33023316

0 commit comments

Comments
 (0)