Blame SOURCES/0003-mcstrans-Do-not-accept-incomplete-contexts.patch

e941f2
From a6e2b2287254b2880e8697707f10bd303ffcc06a Mon Sep 17 00:00:00 2001
a5f30d
From: Petr Lautrbach <plautrba@redhat.com>
a5f30d
Date: Mon, 15 Apr 2019 15:22:51 +0200
a5f30d
Subject: [PATCH] mcstrans: Do not accept incomplete contexts
a5f30d
MIME-Version: 1.0
a5f30d
Content-Type: text/plain; charset=UTF-8
a5f30d
Content-Transfer-Encoding: 8bit
a5f30d
a5f30d
Fixes:
a5f30d
$ python3
a5f30d
> import selinux
a5f30d
> selinux.selinux_raw_context_to_color("xyz_u:xyz_r:xyz_t:")
a5f30d
a5f30d
Traceback (most recent call last):
a5f30d
  File "<stdin>", line 2, in <module>
a5f30d
OSError: [Errno 0] Error
a5f30d
a5f30d
:: [ 10:25:45 ] :: [  BEGIN   ] :: Running 'service mcstransd status'
a5f30d
Redirecting to /bin/systemctl status mcstransd.service
a5f30d
● mcstrans.service - Translates SELinux MCS/MLS labels to human readable form
a5f30d
   Loaded: loaded (/usr/lib/systemd/system/mcstrans.service; disabled; vendor preset: disabled)
a5f30d
   Active: failed (Result: core-dump) since Fri 2019-04-12 10:25:44 EDT; 1s ago
a5f30d
  Process: 16681 ExecStart=/sbin/mcstransd -f (code=dumped, signal=SEGV)
a5f30d
 Main PID: 16681 (code=dumped, signal=SEGV)
a5f30d
a5f30d
systemd[1]: mcstrans.service: Main process exited, code=dumped, status=11/SEGV
a5f30d
systemd[1]: mcstrans.service: Failed with result 'core-dump'.
a5f30d
a5f30d
Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
a5f30d
---
a5f30d
 mcstrans/src/mcscolor.c | 12 ++++++++----
a5f30d
 1 file changed, 8 insertions(+), 4 deletions(-)
a5f30d
a5f30d
diff --git a/mcstrans/src/mcscolor.c b/mcstrans/src/mcscolor.c
e941f2
index a38388501db5..94421a58dee4 100644
a5f30d
--- a/mcstrans/src/mcscolor.c
a5f30d
+++ b/mcstrans/src/mcscolor.c
a5f30d
@@ -272,10 +272,14 @@ static const unsigned precedence[N_COLOR][N_COLOR - 1] = {
a5f30d
 static const secolor_t default_color = { 0x000000, 0xffffff };
a5f30d
 
a5f30d
 static int parse_components(context_t con, char **components) {
a5f30d
-	components[COLOR_USER] = (char *)context_user_get(con);
a5f30d
-	components[COLOR_ROLE] = (char *)context_role_get(con);
a5f30d
-	components[COLOR_TYPE] = (char *)context_type_get(con);
a5f30d
-	components[COLOR_RANGE] = (char *)context_range_get(con);
a5f30d
+	if ((components[COLOR_USER] = (char *)context_user_get(con)) == NULL)
a5f30d
+		return -1;
a5f30d
+	if ((components[COLOR_ROLE] = (char *)context_role_get(con)) == NULL)
a5f30d
+		return -1;
a5f30d
+	if ((components[COLOR_TYPE] = (char *)context_type_get(con)) == NULL)
a5f30d
+		return -1;
a5f30d
+	if ((components[COLOR_RANGE] = (char *)context_range_get(con)) == NULL)
a5f30d
+		return -1;
a5f30d
 
a5f30d
 	return 0;
a5f30d
 }
a5f30d
-- 
e941f2
2.32.0
a5f30d