0
0
mirror of https://github.com/termux/termux-packages.git synced 2025-09-28 21:52:39 +00:00
Files
termux-packages/packages/coreutils/backport-d89387b.patch
Robert Kirkman ef60dba621 fix(main/coreutils): fix undefined behavior in coreutils built with selinux enabled and xattrs disabled
- Fixes https://github.com/termux/termux-packages/issues/23752

Patch created and shared by pixelb

This restores the 'ls -Z' command to its pre-coreutils-9.6 behavior,

and passes these test cases on Samsung Galaxy A70 SM-A705FN with Android 13:

(should not crash)
cd && ls -Z ..

(should not crash)
cd && ls -Z . > out

(should not crash)
ls -Z /storage/emulated/0/

(should show correct output, like 'u:object_r:fuse:s0')
cd /storage/emulated/0 && ls -Z $(pwd)

(should print both directories without crashing)
ls -l /storage/emulated/0 /storage/emulated/0/Download

(should print both directories without crashing)
ls -Z /storage/emulated/0 /storage/emulated/0/Download

(should print both directories without crashing)
ls -lZ /storage/emulated/0 /storage/emulated/0/Download

More information here:

https://github.com/termux/termux-packages/pull/23691#discussion_r1986260242
https://github.com/termux/termux-packages/pull/23756#discussion_r1993138524
2025-03-21 01:15:01 +00:00

35 lines
1.2 KiB
Diff

From d89387b293068773c74f37ebf8fb692ad962b43a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
Date: Thu, 20 Mar 2025 18:40:01 +0000
Subject: [PATCH] ls: fix crash on systems with SELinux but without xattr
support
This was seen on termux with ./configure --disable-xattr
where listxattr() and getxattr() returned ENOTSUP.
Then the valid security context obtained by file_has_aclinfo()
was discounted, and problematically then freed multiple times.
Reported at https://github.com/termux/termux-packages/issues/23752
* src/ls.c (file_has_aclinfo_cache): Only discount the returned
acl info when all components are defaulted due to being unsupported.
---
NEWS | 3 ++-
src/ls.c | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
--- a/src/ls.c
+++ b/src/ls.c
@@ -3327,7 +3327,8 @@ file_has_aclinfo_cache (char const *file, struct fileinfo *f,
errno = 0;
int n = file_has_aclinfo (file, ai, flags);
int err = errno;
- if (f->stat_ok && n <= 0 && !acl_errno_valid (err))
+ if (f->stat_ok && n <= 0 && !acl_errno_valid (err)
+ && (!(flags & ACL_GET_SCONTEXT) || !acl_errno_valid (ai->scontext_err)))
{
unsupported_return = n;
unsupported_scontext = ai->scontext;
--
2.48.1