perform_mounts(): Fix potential leak and fix iteration

We would not free 'concat_path' in all potential paths.
Also, the iteration would not continue potentially.

This was case unlikely to be hit in practise.
This commit is contained in:
Albert S. 2022-10-23 19:48:33 +02:00
parent e711a1d53a
commit ff60ec227d
1 changed files with 12 additions and 11 deletions

View File

@ -869,6 +869,8 @@ static int create_chroot_dirs(const char *chroot_target_path, struct exile_path_
static int perform_mounts(const char *chroot_target_path, struct exile_path_policy *path_policy)
{
while(path_policy != NULL)
{
if(path_policy->policy & EXILE_FS_ALLOW_ALL_READ || path_policy->policy & EXILE_FS_ALLOW_ALL_WRITE)
{
int mount_flags = get_policy_mount_flags(path_policy);
@ -880,8 +882,6 @@ static int perform_mounts(const char *chroot_target_path, struct exile_path_poli
//all we do is bind mounts
mount_flags |= MS_BIND;
if(path_policy->policy & EXILE_FS_ALLOW_ALL_READ || path_policy->policy & EXILE_FS_ALLOW_ALL_WRITE)
{
int ret = mount(path_policy->path, path_inside_chroot, NULL, mount_flags, NULL);
if(ret < 0 )
{
@ -898,9 +898,10 @@ static int perform_mounts(const char *chroot_target_path, struct exile_path_poli
free(path_inside_chroot);
return ret;
}
path_policy = path_policy->next;
free(path_inside_chroot);
}
path_policy = path_policy->next;
}
return 0;
}