From b2a0469394af080573e168b4f750263e3959e7e5 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sat, 24 Dec 2022 20:00:05 -0600 Subject: [PATCH] Security: Check if either 'main' or 'setting' is NULL. Name the void pointer 'setting' as 'void_setting' for consistency purposes. Note that this should not be named 'void_setting' in the header files. --- level_3/fss_write/c/basic/fss_write.c | 10 ++++++++-- level_3/fss_write/c/basic_list/fss_write.c | 10 ++++++++-- level_3/fss_write/c/embedded_list/fss_write.c | 10 ++++++++-- level_3/fss_write/c/extended/fss_write.c | 10 ++++++++-- level_3/fss_write/c/extended_list/fss_write.c | 10 ++++++++-- level_3/fss_write/c/main/fss_write.c | 10 +++++----- level_3/fss_write/c/main/main.c | 6 ++++-- level_3/fss_write/c/payload/fss_write.c | 10 ++++++++-- 8 files changed, 57 insertions(+), 19 deletions(-) diff --git a/level_3/fss_write/c/basic/fss_write.c b/level_3/fss_write/c/basic/fss_write.c index 12c8975..78e7332 100644 --- a/level_3/fss_write/c/basic/fss_write.c +++ b/level_3/fss_write/c/basic/fss_write.c @@ -8,6 +8,8 @@ extern "C" { #ifndef _di_fss_write_basic_process_content_ void fss_write_basic_process_content(fll_program_data_t * const main, void * const void_setting, const bool last) { + if (!main || !void_setting) return; + fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); if (setting->content) { @@ -51,15 +53,19 @@ extern "C" { #endif // _di_fss_write_basic_process_content_ #ifndef _di_fss_write_basic_process_help_ - void fss_write_basic_process_help(fll_program_data_t * const main, void * const setting) { + void fss_write_basic_process_help(fll_program_data_t * const main, void * const void_setting) { + + if (!main || !void_setting) return; - fss_write_basic_print_help(setting, main->message); + fss_write_basic_print_help(void_setting, main->message); } #endif // _di_fss_write_basic_process_help_ #ifndef _di_fss_write_basic_process_object_ void fss_write_basic_process_object(fll_program_data_t * const main, void * const void_setting) { + if (!main || !void_setting) return; + fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); if (setting->object) { diff --git a/level_3/fss_write/c/basic_list/fss_write.c b/level_3/fss_write/c/basic_list/fss_write.c index f80dac2..38d636b 100644 --- a/level_3/fss_write/c/basic_list/fss_write.c +++ b/level_3/fss_write/c/basic_list/fss_write.c @@ -8,6 +8,8 @@ extern "C" { #ifndef _di_fss_write_basic_list_process_content_ void fss_write_basic_list_process_content(fll_program_data_t * const main, void * const void_setting, const bool last) { + if (!main || !void_setting) return; + fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); if (setting->content) { @@ -54,15 +56,19 @@ extern "C" { #endif // _di_fss_write_basic_list_process_content_ #ifndef _di_fss_write_basic_list_process_help_ - void fss_write_basic_list_process_help(fll_program_data_t * const main, void * const setting) { + void fss_write_basic_list_process_help(fll_program_data_t * const main, void * const void_setting) { + + if (!main || !void_setting) return; - fss_write_basic_list_print_help(setting, main->message); + fss_write_basic_list_print_help(void_setting, main->message); } #endif // _di_fss_write_basic_list_process_help_ #ifndef _di_fss_write_basic_list_process_object_ void fss_write_basic_list_process_object(fll_program_data_t * const main, void * const void_setting) { + if (!main || !void_setting) return; + fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); if (setting->object) { diff --git a/level_3/fss_write/c/embedded_list/fss_write.c b/level_3/fss_write/c/embedded_list/fss_write.c index 543661d..9978353 100644 --- a/level_3/fss_write/c/embedded_list/fss_write.c +++ b/level_3/fss_write/c/embedded_list/fss_write.c @@ -8,6 +8,8 @@ extern "C" { #ifndef _di_fss_write_embedded_list_process_content_ void fss_write_embedded_list_process_content(fll_program_data_t * const main, void * const void_setting, const bool last) { + if (!main || !void_setting) return; + fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); if (setting->content) { @@ -59,15 +61,19 @@ extern "C" { #endif // _di_fss_write_embedded_list_process_content_ #ifndef _di_fss_write_embedded_list_process_help_ - void fss_write_embedded_list_process_help(fll_program_data_t * const main, void * const setting) { + void fss_write_embedded_list_process_help(fll_program_data_t * const main, void * const void_setting) { + + if (!main || !void_setting) return; - fss_write_embedded_list_print_help(setting, main->message); + fss_write_embedded_list_print_help(void_setting, main->message); } #endif // _di_fss_write_embedded_list_process_help_ #ifndef _di_fss_write_embedded_list_process_object_ void fss_write_embedded_list_process_object(fll_program_data_t * const main, void * const void_setting) { + if (!main || !void_setting) return; + fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); if (setting->object) { diff --git a/level_3/fss_write/c/extended/fss_write.c b/level_3/fss_write/c/extended/fss_write.c index 86ec242..15b2cfa 100644 --- a/level_3/fss_write/c/extended/fss_write.c +++ b/level_3/fss_write/c/extended/fss_write.c @@ -8,6 +8,8 @@ extern "C" { #ifndef _di_fss_write_extended_process_content_ void fss_write_extended_process_content(fll_program_data_t * const main, void * const void_setting, const bool last) { + if (!main || !void_setting) return; + fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); if (setting->content) { @@ -63,15 +65,19 @@ extern "C" { #endif // _di_fss_write_extended_process_content_ #ifndef _di_fss_write_extended_process_help_ - void fss_write_extended_process_help(fll_program_data_t * const main, void * const setting) { + void fss_write_extended_process_help(fll_program_data_t * const main, void * const void_setting) { + + if (!main || !void_setting) return; - fss_write_extended_print_help(setting, main->message); + fss_write_extended_print_help(void_setting, main->message); } #endif // _di_fss_write_extended_process_help_ #ifndef _di_fss_write_extended_process_object_ void fss_write_extended_process_object(fll_program_data_t * const main, void * const void_setting) { + if (!main || !void_setting) return; + fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); if (setting->object) { diff --git a/level_3/fss_write/c/extended_list/fss_write.c b/level_3/fss_write/c/extended_list/fss_write.c index 1496c2f..e905ce3 100644 --- a/level_3/fss_write/c/extended_list/fss_write.c +++ b/level_3/fss_write/c/extended_list/fss_write.c @@ -8,6 +8,8 @@ extern "C" { #ifndef _di_fss_write_extended_list_process_content_ void fss_write_extended_list_process_content(fll_program_data_t * const main, void * const void_setting, const bool last) { + if (!main || !void_setting) return; + fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); if (setting->content) { @@ -59,15 +61,19 @@ extern "C" { #endif // _di_fss_write_extended_list_process_content_ #ifndef _di_fss_write_extended_list_process_help_ - void fss_write_extended_list_process_help(fll_program_data_t * const main, void * const setting) { + void fss_write_extended_list_process_help(fll_program_data_t * const main, void * const void_setting) { + + if (!main || !void_setting) return; - fss_write_extended_list_print_help(macro_fss_write_setting(setting), main->message); + fss_write_extended_list_print_help(macro_fss_write_setting(void_setting), main->message); } #endif // _di_fss_write_extended_list_process_help_ #ifndef _di_fss_write_extended_list_process_object_ void fss_write_extended_list_process_object(fll_program_data_t * const main, void * const void_setting) { + if (!main || !void_setting) return; + fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); if (setting->object) { diff --git a/level_3/fss_write/c/main/fss_write.c b/level_3/fss_write/c/main/fss_write.c index a07d92f..4ba9537 100644 --- a/level_3/fss_write/c/main/fss_write.c +++ b/level_3/fss_write/c/main/fss_write.c @@ -47,14 +47,14 @@ extern "C" { #endif // _di_fss_write_main_ #ifndef _di_fss_write_process_normal_ - void fss_write_process_normal(fll_program_data_t * const main, void * const setting) { + void fss_write_process_normal(fll_program_data_t * const main, void * const void_setting) { fss_write_process_normal_data( main, - macro_fss_write_setting(setting), - (macro_fss_write_setting(setting)->flag & fss_write_flag_object_e) - ? macro_fss_write_setting(setting)->objects.used - : macro_fss_write_setting(setting)->contentss.used + macro_fss_write_setting(void_setting), + (macro_fss_write_setting(void_setting)->flag & fss_write_flag_object_e) + ? macro_fss_write_setting(void_setting)->objects.used + : macro_fss_write_setting(void_setting)->contentss.used ); } #endif // _di_fss_write_process_normal_ diff --git a/level_3/fss_write/c/main/main.c b/level_3/fss_write/c/main/main.c index 367f2cd..832854e 100644 --- a/level_3/fss_write/c/main/main.c +++ b/level_3/fss_write/c/main/main.c @@ -43,9 +43,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { } #ifndef _di_fss_write_main_process_help_ - void fss_write_main_process_help(fll_program_data_t * const main, void * const setting) { + void fss_write_main_process_help(fll_program_data_t * const main, void * const void_setting) { - fss_write_main_print_help(macro_fss_write_setting(setting), main->message); + if (!main || !void_setting) return; + + fss_write_main_print_help(macro_fss_write_setting(void_setting), main->message); } #endif // _di_fss_write_main_process_help_ diff --git a/level_3/fss_write/c/payload/fss_write.c b/level_3/fss_write/c/payload/fss_write.c index 024b3f6..cc05056 100644 --- a/level_3/fss_write/c/payload/fss_write.c +++ b/level_3/fss_write/c/payload/fss_write.c @@ -6,15 +6,19 @@ extern "C" { #endif #ifndef _di_fss_write_payload_process_help_ - void fss_write_payload_process_help(fll_program_data_t * const main, void * const setting) { + void fss_write_payload_process_help(fll_program_data_t * const main, void * const void_setting) { - fss_write_payload_print_help(macro_fss_write_setting(setting), main->message); + if (!main || !void_setting) return; + + fss_write_payload_print_help(macro_fss_write_setting(void_setting), main->message); } #endif // _di_fss_write_payload_process_help_ #ifndef _di_fss_write_payload_process_pipe_ void fss_write_payload_process_pipe(fll_program_data_t * const main, void * const void_setting) { + if (!main || !void_setting) return; + f_status_t status_pipe = F_none; f_file_t input = f_file_t_initialize; input.id = F_type_descriptor_input_d; @@ -376,6 +380,8 @@ extern "C" { #ifndef _di_fss_write_payload_process_set_ void fss_write_payload_process_set(fll_program_data_t * const main, void * const void_setting) { + if (!main || !void_setting) return; + fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); if ((!(setting->flag & fss_write_flag_partial_e) || (setting->flag & fss_write_flag_partial_e) && (setting->flag & fss_write_flag_object_e))) { -- 1.8.3.1