From: Daniel P. Berrangé Date: Thu, 1 Aug 2019 11:07:47 +0000 (+0100) Subject: tools: fix crash in virt-login-shell if config doesn't exist X-Git-Tag: v5.7.0-rc1~356 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=275bcbebabfb30a171a71d1865c01f10503a96ae;p=thirdparty%2Flibvirt.git tools: fix crash in virt-login-shell if config doesn't exist 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 Signed-off-by: Daniel P. Berrangé --- diff --git a/tools/virt-login-shell.c b/tools/virt-login-shell.c index ee5c04f9c2..b906fa9ed6 100644 --- a/tools/virt-login-shell.c +++ b/tools/virt-login-shell.c @@ -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.