From 1a4063ca209f84331a58e4459506647d97dda22e Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Fri, 3 May 2024 16:32:05 +0200 Subject: [PATCH] security: Fix return types of .probe callbacks MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Daniel P. Berrangé Reviewed-by: Ján Tomko --- src/security/security_apparmor.c | 2 +- src/security/security_selinux.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/security/security_apparmor.c b/src/security/security_apparmor.c index c1dc859751..27184aef7f 100644 --- a/src/security/security_apparmor.c +++ b/src/security/security_apparmor.c @@ -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; diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index aaec34ff8b..e29f627bc2 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1039,7 +1039,7 @@ virSecuritySELinuxReserveLabel(virSecurityManager *mgr, } -static int +static virSecurityDriverStatus virSecuritySELinuxDriverProbe(const char *virtDriver) { if (is_selinux_enabled() <= 0) -- 2.47.3