From 767c244e7c023880b4eb555a07a42f5d8e4b364e Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sat, 24 Dec 2022 19:34:40 -0600 Subject: [PATCH] Security: Check if 'main' is NULL. --- level_3/control/c/control.c | 2 ++ level_3/control/c/control.h | 1 + level_3/controller/c/controller.c | 2 ++ level_3/controller/c/controller.h | 1 + 4 files changed, 6 insertions(+) diff --git a/level_3/control/c/control.c b/level_3/control/c/control.c index 4958d1c..5b57bcd 100644 --- a/level_3/control/c/control.c +++ b/level_3/control/c/control.c @@ -10,6 +10,8 @@ extern "C" { #ifndef _di_control_print_help_ f_status_t control_print_help(const fll_program_data_t * const main) { + if (!main) return F_output_not; + flockfile(main->output.to.stream); fll_program_print_help_header(main->output.to, main->context, control_program_name_long_s, control_program_version_s); diff --git a/level_3/control/c/control.h b/level_3/control/c/control.h index c218b00..2d4f23a 100644 --- a/level_3/control/c/control.h +++ b/level_3/control/c/control.h @@ -65,6 +65,7 @@ extern "C" { * * @return * F_none on success. + * F_output_not on success, but no printing is performed. * * @see control_main() */ diff --git a/level_3/controller/c/controller.c b/level_3/controller/c/controller.c index 500f7dd..a88cda6 100644 --- a/level_3/controller/c/controller.c +++ b/level_3/controller/c/controller.c @@ -15,6 +15,8 @@ extern "C" { #ifndef _di_controller_print_help_ f_status_t controller_print_help(controller_main_t * const main) { + if (!main) return F_output_not; + controller_lock_print(main->output.to, 0); fll_program_print_help_header(main->output.to, main->context, *main->program_name_long, controller_program_version_s); diff --git a/level_3/controller/c/controller.h b/level_3/controller/c/controller.h index e30842a..69c5971 100644 --- a/level_3/controller/c/controller.h +++ b/level_3/controller/c/controller.h @@ -91,6 +91,7 @@ extern "C" { * * @return * F_none on success. + * F_output_not on success, but no printing is performed. * * @see controller_main() */ -- 1.8.3.1