]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
selinux: update mac_selinux_free()
authorChristian Göttsche <cgzones@googlemail.com>
Tue, 23 Jun 2020 10:26:59 +0000 (12:26 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 24 Jun 2020 06:38:34 +0000 (08:38 +0200)
* 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

index 0d7a7e1fbed9d53c075dd616dca211218588b0d7..1b052a4c68bd458b1f75086bed01a440438be44e 100644 (file)
@@ -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;