selinux: fix potential double free crash in child process
Before returning from function we should reset ret to NULL, thus cleanup function is nop. Also context_str() returns pointer to a string containing context but not a copy, hence we must make copy it explicitly.
This commit is contained in:
+2
-1
@@ -334,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;
|
||||
@@ -348,6 +348,7 @@ int label_get_child_mls_label(int socket_fd, const char *exe, char **label) {
|
||||
}
|
||||
|
||||
*label = ret;
|
||||
ret = NULL;
|
||||
r = 0;
|
||||
|
||||
out:
|
||||
|
||||
Reference in New Issue
Block a user