From 3d9fbea43e8d1d87b10dd8c26cec7ca1db919b19 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Christian=20G=C3=B6ttsche?= Date: Tue, 23 Jun 2020 12:26:59 +0200 Subject: [PATCH] selinux: update mac_selinux_free() * Drop mac_selinux_use() condition from mac_selinux_free(): if the passed pointer holds memory we want to free it even if SELinux is disabled * Drop NULL-check cause man:freecon(3) states that freecon(NULL) is a well-defined NOP * Assert that on non-SELinux builds the passed pointer is always NULL, to avoid memory leaks --- src/basic/selinux-util.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/basic/selinux-util.c b/src/basic/selinux-util.c index 0d7a7e1fbed..1b052a4c68b 100644 --- a/src/basic/selinux-util.c +++ b/src/basic/selinux-util.c @@ -376,13 +376,9 @@ int mac_selinux_get_child_mls_label(int socket_fd, const char *exe, const char * char* mac_selinux_free(char *label) { #if HAVE_SELINUX - if (!label) - return NULL; - - if (!mac_selinux_use()) - return NULL; - freecon(label); +#else + assert(!label); #endif return NULL; -- 2.47.3