render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
43fe83
From 248d2007a780bd141298cf0b330342b45f83dde8 Mon Sep 17 00:00:00 2001
43fe83
Message-Id: <248d2007a780bd141298cf0b330342b45f83dde8.1377873639.git.jdenemar@redhat.com>
43fe83
From: "Daniel P. Berrange" <berrange@redhat.com>
43fe83
Date: Tue, 13 Aug 2013 15:20:42 +0100
43fe83
Subject: [PATCH] Fix double-free and broken logic in virt-login-shell
43fe83
43fe83
For https://bugzilla.redhat.com/show_bug.cgi?id=988491
43fe83
43fe83
The virLoginShellAllowedUser method must not free the 'groups'
43fe83
parameter it is given, as that is owned by the caller.
43fe83
43fe83
The virLoginShellAllowedUser method should be checking
43fe83
'!*ptr' (ie empty string) rather than '!ptr' (NULL string)
43fe83
since the latter cannot be true.
43fe83
43fe83
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
43fe83
(cherry picked from commit ac692e3af231651304a93d63cb54049d9e3d50f8)
43fe83
---
43fe83
 tools/virt-login-shell.c | 4 +---
43fe83
 1 file changed, 1 insertion(+), 3 deletions(-)
43fe83
43fe83
diff --git a/tools/virt-login-shell.c b/tools/virt-login-shell.c
43fe83
index b8f1a28..b27e44f 100644
43fe83
--- a/tools/virt-login-shell.c
43fe83
+++ b/tools/virt-login-shell.c
43fe83
@@ -85,7 +85,7 @@ static int virLoginShellAllowedUser(virConfPtr conf,
43fe83
                 */
43fe83
                 if (pp->str[0] == '%') {
43fe83
                     ptr = &pp->str[1];
43fe83
-                    if (!ptr)
43fe83
+                    if (!*ptr)
43fe83
                         continue;
43fe83
                     for (i = 0; groups[i]; i++) {
43fe83
                         if (!(gname = virGetGroupName(groups[i])))
43fe83
@@ -96,7 +96,6 @@ static int virLoginShellAllowedUser(virConfPtr conf,
43fe83
                         }
43fe83
                         VIR_FREE(gname);
43fe83
                     }
43fe83
-                    VIR_FREE(groups);
43fe83
                     continue;
43fe83
                 }
43fe83
                 if (fnmatch(pp->str, name, 0) == 0) {
43fe83
@@ -109,7 +108,6 @@ static int virLoginShellAllowedUser(virConfPtr conf,
43fe83
     virReportSystemError(EPERM, _("%s not listed as an allowed_users in %s"), name, conf_file);
43fe83
 cleanup:
43fe83
     VIR_FREE(gname);
43fe83
-    VIR_FREE(groups);
43fe83
     return ret;
43fe83
 }
43fe83
 
43fe83
-- 
43fe83
1.8.3.2
43fe83