bugfix: qssb_enable_policy: pointer to stack-local variable

This commit is contained in:
Albert S. 2019-11-17 12:45:01 +01:00
parent fbf51e095f
commit 8f104a231c

4
qssb.h
View File

@ -482,11 +482,11 @@ int qssb_enable_policy(struct qssb_policy *policy)
if(policy->chroot_target_path == NULL) if(policy->chroot_target_path == NULL)
{ {
char target_dir[PATH_MAX]; char *target_dir = calloc(1, PATH_MAX * sizeof(char));
char random_str[17]; char random_str[17];
if(random_string(random_str, sizeof(random_str)) == 16) if(random_string(random_str, sizeof(random_str)) == 16)
{ {
int res = snprintf(target_dir, sizeof(target_dir), "%s/.sandbox_%" PRIdMAX "_%s", QSSB_TEMP_DIR, (intmax_t)getpid(), random_str); int res = snprintf(target_dir, PATH_MAX, "%s/.sandbox_%" PRIdMAX "_%s", QSSB_TEMP_DIR, (intmax_t)getpid(), random_str);
if(res < 0) if(res < 0)
{ {
QSSB_LOG_ERROR("qssb: qssb_enable_policy: error during path concatination\n"); QSSB_LOG_ERROR("qssb: qssb_enable_policy: error during path concatination\n");