From 1f909cf5a5826d196b87d6a8c67973c672056eff Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sun, 5 Mar 2023 11:59:23 -0600 Subject: [PATCH] Cleanup: Add explicit buffer empty checks in owner and group funcctions. --- level_3/fake/c/private-make.c | 12 ++++++++++++ level_3/fake/c/private-make.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/level_3/fake/c/private-make.c b/level_3/fake/c/private-make.c index 642e986..97740cc 100644 --- a/level_3/fake/c/private-make.c +++ b/level_3/fake/c/private-make.c @@ -42,6 +42,12 @@ extern "C" { #ifndef _di_fake_make_get_id_group_ f_status_t fake_make_get_id_group(fake_data_t * const data, const fl_print_t print, const f_string_static_t buffer, gid_t *id) { + if (!buffer.used) { + fll_error_print(print, F_parameter, "fake_make_get_id_group", F_true); + + return F_status_set_error(F_parameter); + } + f_number_unsigned_t number = 0; f_status_t status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, buffer, &number); @@ -137,6 +143,12 @@ extern "C" { #ifndef _di_fake_make_get_id_owner_ f_status_t fake_make_get_id_owner(fake_data_t * const data, const fl_print_t print, const f_string_static_t buffer, uid_t *id) { + if (!buffer.used) { + fll_error_print(print, F_parameter, "fake_make_get_id_owner", F_true); + + return F_status_set_error(F_parameter); + } + f_number_unsigned_t number = 0; f_status_t status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, buffer, &number); diff --git a/level_3/fake/c/private-make.h b/level_3/fake/c/private-make.h index 365aae7..e7b2272 100644 --- a/level_3/fake/c/private-make.h +++ b/level_3/fake/c/private-make.h @@ -110,6 +110,8 @@ extern "C" { * The NULL terminated path to get the relative path of. * * @return + * F_none on success. + * * Status codes (with error bit) are returned on any problem. */ #ifndef _di_fake_make_path_relative_ -- 1.8.3.1