[libvirt] [PATCH] selinux: fix segfault in virSecuritySELinuxMCSGetProcessRange

Ján Tomko jtomko at redhat.com
Tue Jun 4 10:16:05 UTC 2013


From: James Gilliland <neclimdul at gmail.com>

https://bugzilla.redhat.com/show_bug.cgi?id=969878
---
 src/security/security_selinux.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
index b862fbf..3d8195c 100644
--- a/src/security/security_selinux.c
+++ b/src/security/security_selinux.c
@@ -189,6 +189,7 @@ virSecuritySELinuxMCSGetProcessRange(char **sens,
     context_t ourContext = NULL;
     char *cat = NULL;
     char *tmp;
+    char *contextRange;
     int ret = -1;
 
     if (getcon_raw(&ourSecContext) < 0) {
@@ -202,8 +203,14 @@ virSecuritySELinuxMCSGetProcessRange(char **sens,
                              ourSecContext);
         goto cleanup;
     }
+    if (!(contextRange = context_range_get(ourContext))) {
+        virReportSystemError(errno,
+                             _("Unable to parse current SELinux context range '%s'"),
+                             ourSecContext);
+        goto cleanup;
+    }
 
-    if (VIR_STRDUP(*sens, context_range_get(ourContext)) < 0)
+    if (VIR_STRDUP(*sens, contextRange) < 0)
         goto cleanup;
 
     /* Find and blank out the category part (if any) */
-- 
1.8.1.5




More information about the libvir-list mailing list