Skip to contentSkip to conversation

mcstrans: increase context length limit in secolor.conf

PATCH In review Stephen Smalley 1 participant 2 messages Jul 21 – Jul 24 SELinux security module

lore
Share & tools
lore

Stephen Smalley

author maintainer
#0 lore raw

PATCH 1/1 mcstrans: increase context length limit in secolor.conf

The 255 character limit on context strings in secolor.conf causes mcstrans color translations to fail for legitimate contexts.

---
 mcstrans/src/mcscolor.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mcstrans/src/mcscolor.c +2 -2
index fd8a248b..e4a0db74 100644
@@ -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++)
Signature · 1 line
2.55.0
author maintainer
#1 lore raw
Quoted 6 lines · Stephen Smalley

The 255 character limit on context strings in secolor.conf causes mcstrans color translations to fail for legitimate contexts.

Merged, maybe switch to %ms in the future.

Quoted 29 lines
---
 mcstrans/src/mcscolor.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mcstrans/src/mcscolor.c +2 -3
index fd8a248b..e4a0db74 100644
@@ -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