chiark / gitweb /
selinux: fix potential double free crash in child process
[elogind.git] / src / shared / label.c
index 02b41f02d8f35c943616cd917ae62d12265b1ac3..69d4616183b3bf4dcdb04e5bfde8a137384bd35f 100644 (file)
@@ -252,9 +252,10 @@ fail:
 
 int label_get_our_label(char **label) {
         int r = -EOPNOTSUPP;
-        char *l = NULL;
 
 #ifdef HAVE_SELINUX
+        char *l = NULL;
+
         r = getcon(&l);
         if (r < 0)
                 return r;
@@ -333,7 +334,7 @@ int label_get_child_mls_label(int socket_fd, const char *exe, char **label) {
         }
 
         freecon(mycon);
-        mycon = context_str(bcon);
+        mycon = strdup(context_str(bcon));
         if (!mycon) {
                 r = -errno;
                 goto out;
@@ -347,6 +348,7 @@ int label_get_child_mls_label(int socket_fd, const char *exe, char **label) {
         }
 
         *label = ret;
+        ret = NULL;
         r = 0;
 
 out: