]> xenbits.xensource.com Git - libvirt.git/commitdiff
tools: fix crash in virt-login-shell if config doesn't exist
authorDaniel P. Berrangé <berrange@redhat.com>
Thu, 1 Aug 2019 11:07:47 +0000 (12:07 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Wed, 7 Aug 2019 15:54:01 +0000 (16:54 +0100)
If the 'allowed_users' config setting in virt-login-shell.conf
does not exist, we dereference a NULL pointer resulting in a
crash. We should check for this case and thus ensure the user
is denied access gracefully.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
tools/virt-login-shell.c

index ee5c04f9c2c5174656759405cbd77d42cfacf641..b906fa9ed689ed9c79ea6b4dc02692b2be6b4033 100644 (file)
@@ -54,7 +54,7 @@ static int virLoginShellAllowedUser(virConfPtr conf,
         goto cleanup;
 
 
-    for (entries = users; *entries; entries++) {
+    for (entries = users; entries && *entries; entries++) {
         char *entry = *entries;
         /*
           If string begins with a % this indicates a linux group.