ls: fix crash with --context

* src/ls.c (main): Flag that we need to stat()
if we're going to get security context (call file_has_aclinfo_cache).
(file_has_aclinfo_cache): Be defensive and only lookup the device
for the file if the stat has been performed.
(has_capability_cache): Likewise.
* tests/ls/selinux-segfault.sh: Add a test case.
* NEWS: Mention the bug fix.
Reported by Bruno Haible.
This commit is contained in:
Pádraig Brady
2025-01-17 17:29:34 +00:00
parent 23fcbeff42
commit 915004f403
3 changed files with 13 additions and 5 deletions

View File

@@ -30,4 +30,7 @@ mkdir sedir || framework_failure_
ln -sf missing sedir/broken || framework_failure_
returns_ 1 ls -L -R -Z -m sedir > out || fail=1
# ls 9.6 would segfault with the following
ls -Z . > out || fail=1
Exit $fail