From 4ad511c78c011dad17a9917ad9656b16e0a30219 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Wed, 11 Sep 2024 00:19:55 -0500 Subject: [PATCH] Update: Improve robustness of the fll_control_group_prepare() function. Add additional existence checks before attempting to create a directory within the cgroup path. --- level_2/fll_control_group/c/control_group.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/level_2/fll_control_group/c/control_group.c b/level_2/fll_control_group/c/control_group.c index 3e886f3..fba715e 100644 --- a/level_2/fll_control_group/c/control_group.c +++ b/level_2/fll_control_group/c/control_group.c @@ -33,8 +33,14 @@ extern "C" { memcpy(path.string + control_group.path.used, control_group.groups.array[i].string, sizeof(f_char_t) * control_group.groups.array[i].used); path.string[path.used] = 0; - status = fl_directory_create(path, F_file_mode_all_rwx_d); - if (F_status_is_error(status)) break; + status = f_directory_exists(path); + if (status == F_false) return F_status_set_error(F_directory_not); + if (F_status_is_error(status)) return status; + + if (status == F_file_found_not) { + status = fl_directory_create(path, F_file_mode_all_rwx_d); + if (F_status_is_error(status)) return status; + } } // for if (F_status_is_error(status)) return status; -- 1.8.3.1