]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
security: Fix return types of .probe callbacks
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 3 May 2024 14:32:05 +0000 (16:32 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 14 May 2024 13:11:30 +0000 (15:11 +0200)
The .probe member of virSecurityDriver struct is declared to
return virSecurityDriverStatus enum. But there are two instances
(AppArmorSecurityManagerProbe() and
virSecuritySELinuxDriverProbe()) where callbacks are defined to
return an integer. This is an undefined behavior because integer
has strictly bigger space of possible values than the enum.

Defined those aforementioned callbacks so that they return the
correct enum instead of int.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/security/security_apparmor.c
src/security/security_selinux.c

index c1dc859751d41d4c265d647a89b96b486fb6b0e7..27184aef7fd6ba72e881e100c53386f66214ec03 100644 (file)
@@ -315,7 +315,7 @@ AppArmorSetSecurityHostLabel(virSCSIVHostDevice *dev G_GNUC_UNUSED,
 }
 
 /* Called on libvirtd startup to see if AppArmor is available */
-static int
+static virSecurityDriverStatus
 AppArmorSecurityManagerProbe(const char *virtDriver G_GNUC_UNUSED)
 {
     g_autofree char *template_qemu = NULL;
index aaec34ff8bd942cae6965bdabfd04d4af3087fa9..e29f627bc2609525ab4c56da34bcd46e57c1f792 100644 (file)
@@ -1039,7 +1039,7 @@ virSecuritySELinuxReserveLabel(virSecurityManager *mgr,
 }
 
 
-static int
+static virSecurityDriverStatus
 virSecuritySELinuxDriverProbe(const char *virtDriver)
 {
     if (is_selinux_enabled() <= 0)