[PATCH] mcstrans: increase context length limit in secolor.conf

Stephen Smalley <[email protected]> Tue, 21 Jul 2026 13:53:02 -0400
Newsgroups org.kernel.vger.selinux
Message-ID <[email protected]>
The 255 character limit on context strings in secolor.conf causes
mcstrans color translations to fail for legitimate contexts.

Fixes: https://github.com/SELinuxProject/selinux/issues/333
Signed-off-by: Stephen Smalley <[email protected]>
---
 mcstrans/src/mcscolor.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mcstrans/src/mcscolor.c b/mcstrans/src/mcscolor.c
index fd8a248b..e4a0db74 100644
--- a/mcstrans/src/mcscolor.c
+++ b/mcstrans/src/mcscolor.c
@@ -225,7 +225,7 @@ static int add_mnemonic(const char *name, uint32_t color)
    May modify the data pointed to by the buffer parameter */
 static int process_color(char *buffer, int line)
 {
-	char rule[10], pat[256], f[256], b[256];
+	char rule[10], pat[4096], f[256], b[256];
 	uint32_t i, fg, bg;
 	int ret;
 
@@ -234,7 +234,7 @@ static int process_color(char *buffer, int line)
 	if (buffer[0] == '#' || buffer[0] == '\0')
 		return 0;
 
-	ret = sscanf(buffer, "%8s %255s = %255s %255s", rule, pat, f, b);
+	ret = sscanf(buffer, "%8s %4095s = %255s %255s", rule, pat, f, b);
 	if (ret == 4) {
 		if (find_mnemonic(f, &fg) == 0 && find_mnemonic(b, &bg) == 0)
 			for (i = 0; i < N_COLOR; i++)
-- 
2.55.0