Skip to content

Commit b1e6fde

Browse files
devnexennikic
authored andcommitted
Fix leaks for AppArmor based distros in case the profile creation fails
Closes GH-7646.
1 parent 5380b41 commit b1e6fde

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

sapi/fpm/fpm/fpm_unix.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,16 +425,21 @@ int fpm_unix_init_child(struct fpm_worker_pool_s *wp) /* {{{ */
425425
new_con = malloc(strlen(con) + strlen(wp->config->apparmor_hat) + 3); // // + 0 Byte
426426
if (!new_con) {
427427
zlog(ZLOG_SYSERROR, "[pool %s] failed to allocate memory for apparmor hat change.", wp->config->name);
428+
free(con);
428429
return -1;
429430
}
430431

431432
if (0 > sprintf(new_con, "%s//%s", con, wp->config->apparmor_hat)) {
432433
zlog(ZLOG_SYSERROR, "[pool %s] failed to construct apparmor confinement.", wp->config->name);
434+
free(con);
435+
free(new_con);
433436
return -1;
434437
}
435438

436439
if (0 > aa_change_profile(new_con)) {
437440
zlog(ZLOG_SYSERROR, "[pool %s] failed to change to new confinement (%s). Please check if \"/proc/*/attr/current\" is read and writeable and \"change_profile -> %s//*\" is allowed.", wp->config->name, new_con, con);
441+
free(con);
442+
free(new_con);
438443
return -1;
439444
}
440445

0 commit comments

Comments
 (0)