From 0fda79562ddd3af9558dd6fde4d963191334456a Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Wed, 16 Feb 2022 21:05:06 -0600 Subject: [PATCH] Update: Console improvements with related security fix. Add f_console_environment_process() to process environment variable data passed via main(). Add appropriate testing. Setup all level 3 (programs) to have the environment data (envp). The level 3 currently do not utilize this. While looking at the tests, I realized that I noticed that I did not fully verify the sanity of the passed argc, argv, and now envp. This is a security issue in that invalid data (argc could be wrong, argv could be NULL, etc..) could result in an invalid read. Update the f_console_parameter_process() to verify the argc and argv data (f_console_parameter_process() doesn't utilize envp). Improve tests to catch these potential problems. Return F_data_not (without error bit) to represent that there is no argc, argv is NULL, or when argv[0] is NULL. Change the previous F_data_not return to instead return F_complete_not (without error bit) to represent that all of the expected values were not found. Update functions to use "const" after the asterisk representing the parameter pointer. --- level_0/f_console/c/console.c | 83 +++++- level_0/f_console/c/console.h | 33 ++- level_0/f_console/c/console/common.h | 5 +- level_0/f_console/data/build/settings-tests | 2 +- .../unit/c/test-console-environment_process.c | 122 ++++++++ .../unit/c/test-console-environment_process.h | 38 +++ .../tests/unit/c/test-console-parameter_process.c | 319 ++++++++++++++++----- .../tests/unit/c/test-console-parameter_process.h | 14 + level_0/f_console/tests/unit/c/test-console.c | 7 + level_0/f_console/tests/unit/c/test-console.h | 1 + level_0/f_string/c/string/common.h | 2 +- level_0/f_string/c/string/static.c | 0 level_0/f_string/c/string/static.h | 0 level_3/byte_dump/c/main.c | 4 +- level_3/control/c/main.c | 4 +- level_3/controller/c/main.c | 4 +- level_3/fake/c/main.c | 4 +- level_3/firewall/c/main.c | 4 +- level_3/fss_basic_list_read/c/main.c | 2 +- level_3/fss_basic_list_write/c/main.c | 4 +- level_3/fss_basic_read/c/main.c | 2 +- level_3/fss_basic_write/c/main.c | 4 +- level_3/fss_embedded_list_read/c/main.c | 4 +- level_3/fss_embedded_list_write/c/main.c | 4 +- level_3/fss_extended_list_read/c/main.c | 2 +- level_3/fss_extended_list_write/c/main.c | 4 +- level_3/fss_extended_read/c/main.c | 2 +- level_3/fss_extended_write/c/main.c | 4 +- level_3/fss_identify/c/main.c | 4 +- level_3/fss_payload_read/c/main.c | 2 +- level_3/fss_payload_write/c/main.c | 4 +- level_3/fss_status_code/c/main.c | 4 +- level_3/iki_read/c/main.c | 4 +- level_3/iki_write/c/main.c | 4 +- level_3/status_code/c/main.c | 4 +- level_3/utf8/c/main.c | 4 +- 36 files changed, 579 insertions(+), 129 deletions(-) create mode 100644 level_0/f_console/tests/unit/c/test-console-environment_process.c create mode 100644 level_0/f_console/tests/unit/c/test-console-environment_process.h create mode 100644 level_0/f_string/c/string/static.c create mode 100644 level_0/f_string/c/string/static.h diff --git a/level_0/f_console/c/console.c b/level_0/f_console/c/console.c index 87c03a3..1b0aaa1 100644 --- a/level_0/f_console/c/console.c +++ b/level_0/f_console/c/console.c @@ -4,8 +4,67 @@ extern "C" { #endif +#ifndef _di_f_console_environment_process_ + f_status_t f_console_environment_process(const f_console_arguments_t arguments, f_string_maps_t * const environment) { + #ifndef _di_level_0_parameter_checking_ + if (!environment) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_f + + if (!arguments.envp) { + return F_data_not; + } + + f_array_length_t total = 0; + + while (arguments.envp[total]) { + ++total; + } // while + + if (!total) { + return F_data_not; + } + + { + const f_status_t status = f_string_maps_increase_by(total, environment); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; arguments.envp[i]; ++i) { + + for (total = 0; arguments.envp[i][total]; ++total) { + if (arguments.envp[i][total] == f_string_ascii_equal_s.string[0]) break; + } // for + + if (total) { + environment->array[environment->used].name.string = arguments.envp[i]; + environment->array[environment->used].name.used = total; + environment->array[environment->used].name.size = 0; + + if (arguments.envp[i][++total]) { + environment->array[environment->used].value.string = arguments.envp[i] + total; + environment->array[environment->used].value.used = 0; + environment->array[environment->used].value.size = 0; + + for (; arguments.envp[i][total]; ++total) { + ++environment->array[environment->used].value.used; + } // for + } + else { + environment->array[environment->used].value.string = 0; + environment->array[environment->used].value.used = 0; + environment->array[environment->used].value.size = 0; + } + + ++environment->used; + } + } // for + + return F_none; + } +#endif // _di_f_console_environment_process_ + #ifndef _di_f_console_identify_ - f_status_t f_console_identify(const f_string_t input, f_console_id_t *result) { + f_status_t f_console_identify(const f_string_t input, f_console_id_t * const result) { #ifndef _di_level_0_parameter_checking_ if (!result) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_f @@ -55,7 +114,7 @@ extern "C" { #endif // _di_f_console_identify_ #ifndef _di_f_console_parameter_prioritize_left_ - f_status_t f_console_parameter_prioritize_left(const f_console_parameters_t parameters, const f_console_parameter_ids_t choices, f_console_parameter_id_t *decision) { + f_status_t f_console_parameter_prioritize_left(const f_console_parameters_t parameters, const f_console_parameter_ids_t choices, f_console_parameter_id_t * const decision) { #ifndef _di_level_0_parameter_checking_ if (!decision) return F_status_set_error(F_parameter); if (!choices.id) return F_status_set_error(F_parameter); @@ -104,7 +163,7 @@ extern "C" { #endif // _di_f_console_parameter_prioritize_left_ #ifndef _di_f_console_parameter_prioritize_right_ - f_status_t f_console_parameter_prioritize_right(const f_console_parameters_t parameters, const f_console_parameter_ids_t choices, f_console_parameter_id_t *decision) { + f_status_t f_console_parameter_prioritize_right(const f_console_parameters_t parameters, const f_console_parameter_ids_t choices, f_console_parameter_id_t * const decision) { #ifndef _di_level_0_parameter_checking_ if (!decision) return F_status_set_error(F_parameter); if (!choices.id) return F_status_set_error(F_parameter); @@ -158,15 +217,15 @@ extern "C" { if (!parameters) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - f_status_t status = F_none; - parameters->arguments.used = 0; - if (arguments.argc) { - status = f_string_dynamics_increase_by(arguments.argc, ¶meters->arguments); - if (F_status_is_error(status)) return status; + if (!arguments.argc || !arguments.argv || !arguments.argv[0]) { + return F_data_not; } + f_status_t status = status = f_string_dynamics_increase_by(arguments.argc, ¶meters->arguments); + if (F_status_is_error(status)) return status; + // Append the program name parameter. parameters->arguments.array[parameters->arguments.used].string = arguments.argv[0]; parameters->arguments.array[parameters->arguments.used].used = strnlen(arguments.argv[0], F_console_parameter_size_d); @@ -192,7 +251,7 @@ extern "C" { uint8_t width = 0; - while (location < arguments.argc) { + while (location < arguments.argc && arguments.argv[location]) { parameters->arguments.array[parameters->arguments.used].string = arguments.argv[location]; parameters->arguments.array[parameters->arguments.used].used = strnlen(arguments.argv[location], F_console_parameter_size_d); @@ -398,7 +457,7 @@ extern "C" { } // while // Make sure the entire parameters arguments array is populated. - for (; location < arguments.argc; ++location) { + for (; location < arguments.argc && arguments.argv[location]; ++location) { parameters->arguments.array[parameters->arguments.used].string = arguments.argv[location]; parameters->arguments.array[parameters->arguments.used].used = strnlen(arguments.argv[location], F_console_parameter_size_d); @@ -411,8 +470,8 @@ extern "C" { return status; } - if (needs_value.used > 0) { - status = F_data_not; + if (needs_value.used) { + status = F_complete_not; } else { status = F_none; diff --git a/level_0/f_console/c/console.h b/level_0/f_console/c/console.h index c32163a..bf2cb95 100644 --- a/level_0/f_console/c/console.h +++ b/level_0/f_console/c/console.h @@ -29,6 +29,30 @@ extern "C" { #endif /** + * Transcribe the NULL terminated environment strings into maps. + * + * All values are appended to the environment maps. + * + * @param parameters + * The parameters to process. + * @param environment + * Maps representing the environment variable names and values. + * Both the name and the value strings may not be NULL terminated. + * Both the name and the value strings may be pointers to the envp memory addresses. + * + * @return + * F_none on success. + * F_data_not if the arguments.envp pointer is NULL or there are no environment variables in arguments.envp. + * + * Errors (with error bit) from: f_string_maps_increase_by(). + * + * @see f_string_maps_increase_by() + */ +#ifndef _di_f_console_environment_process_ + extern f_status_t f_console_environment_process(const f_console_arguments_t arguments, f_string_maps_t * const environment); +#endif // _di_f_console_environment_process_ + +/** * Determine the type code represented by the given input parameter. * * @param input @@ -41,7 +65,7 @@ extern "C" { * F_data_not the input string is empty. */ #ifndef _di_f_console_identify_ - extern f_status_t f_console_identify(const f_string_t input, f_console_id_t *result); + extern f_status_t f_console_identify(const f_string_t input, f_console_id_t * const result); #endif // _di_f_console_identify_ /** @@ -72,7 +96,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_console_parameter_prioritize_left_ - extern f_status_t f_console_parameter_prioritize_left(const f_console_parameters_t parameters, const f_console_parameter_ids_t choices, f_console_parameter_id_t *decision); + extern f_status_t f_console_parameter_prioritize_left(const f_console_parameters_t parameters, const f_console_parameter_ids_t choices, f_console_parameter_id_t * const decision); #endif // _di_f_console_parameter_prioritize_left_ /** @@ -103,7 +127,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_console_parameter_prioritize_right_ - extern f_status_t f_console_parameter_prioritize_right(const f_console_parameters_t parameters, const f_console_parameter_ids_t choices, f_console_parameter_id_t *decision); + extern f_status_t f_console_parameter_prioritize_right(const f_console_parameters_t parameters, const f_console_parameter_ids_t choices, f_console_parameter_id_t * const decision); #endif // _di_f_console_parameter_prioritize_right_ /** @@ -136,7 +160,8 @@ extern "C" { * * @return * F_none on success. - * F_data_not if "values" parameters were expected but not found. + * F_data_not if argc is 0, argv is a NULL pointer, or if argv[0] is NULL. + * F_complete_not if "values" parameters were expected but not found. * * F_array_too_large (with error bit) if a buffer would exceed max length. * F_failure (with error bit) if width is not long enough to convert when processing arguments as UTF-8. diff --git a/level_0/f_console/c/console/common.h b/level_0/f_console/c/console/common.h index 11d84a4..c578d91 100644 --- a/level_0/f_console/c/console/common.h +++ b/level_0/f_console/c/console/common.h @@ -389,11 +389,12 @@ extern "C" { const f_number_unsigned_t argc; const f_string_t *argv; + const f_string_t *envp; } f_console_arguments_t; - #define f_console_arguments_t_initialize { 0, 0 } + #define f_console_arguments_t_initialize { 0, 0, 0 } - #define macro_f_console_arguments_t_initialize(argc, argv) { argc, argv } + #define macro_f_console_arguments_t_initialize(argc, argv, envp) { argc, argv, envp } #endif // _di_f_console_arguments_t_ /** diff --git a/level_0/f_console/data/build/settings-tests b/level_0/f_console/data/build/settings-tests index ab9e847..f35e3f0 100644 --- a/level_0/f_console/data/build/settings-tests +++ b/level_0/f_console/data/build/settings-tests @@ -19,7 +19,7 @@ build_libraries -lc -lcmocka build_libraries-individual -lf_memory -lf_string -lf_type_array -lf_utf -lf_console build_libraries-level -lfll_0 build_libraries-monolithic -lfll -build_sources_program test-console-identify.c test-console-parameter_prioritize_left.c test-console-parameter_prioritize_right.c test-console-parameter_process.c test-console-parameters_delete.c test-console-parameters_destroy.c test-console.c +build_sources_program test-console-environment_process.c test-console-identify.c test-console-parameter_prioritize_left.c test-console-parameter_prioritize_right.c test-console-parameter_process.c test-console-parameters_delete.c test-console-parameters_destroy.c test-console.c build_script no build_shared yes build_static no diff --git a/level_0/f_console/tests/unit/c/test-console-environment_process.c b/level_0/f_console/tests/unit/c/test-console-environment_process.c new file mode 100644 index 0000000..23f3812 --- /dev/null +++ b/level_0/f_console/tests/unit/c/test-console-environment_process.c @@ -0,0 +1,122 @@ +#include "test-console.h" +#include "test-console-environment_process.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_console_environment_process__data_not(void **state) { + + const f_string_t *argv = 0; + const f_string_t *envp = 0; + + // Test both a valid and an invalid argc. + for (uint8_t argc = 0; argc < 2; ++argc) { + + f_string_maps_t maps = f_string_maps_t_initialize; + + const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, envp); + + { + const f_status_t status = f_console_environment_process(arguments, &maps); + + assert_int_equal(status, F_data_not); + } + + f_string_maps_resize(0, &maps); + } // for +} + +#ifndef _di_level_0_parameter_checking_ + void test__f_console_environment_process__parameter_checking(void **state) { + + const f_console_arguments_t arguments = f_console_arguments_t_initialize; + + { + const f_status_t status = f_console_environment_process(arguments, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } + } +#endif // _di_level_0_parameter_checking_ + +void test__f_console_environment_process__works(void **state) { + + const uint8_t argc = 0; + const f_string_t *argv = 0; + const f_string_t envp[] = { + "a=b", + "c_d=e f g", + "H=i=i=i", + "j_j=k-ake!", + "l012=", + 0, + }; + + const f_string_t names[] = { + "a", + "c_d", + "H", + "j_j", + "l012", + 0, + }; + + const f_string_t values[] = { + "b", + "e f g", + "i=i=i", + "k-ake!", + "", + 0, + }; + + f_string_maps_t maps = f_string_maps_t_initialize; + + const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, envp); + + { + const f_status_t status = f_console_environment_process(arguments, &maps); + + assert_int_equal(status, F_none); + assert_int_equal(maps.used, 5); + assert_int_equal(maps.array[0].name.used, 1); + assert_int_equal(maps.array[0].value.used, 1); + assert_int_equal(maps.array[1].name.used, 3); + assert_int_equal(maps.array[1].value.used, 5); + assert_int_equal(maps.array[2].name.used, 1); + assert_int_equal(maps.array[2].value.used, 5); + assert_int_equal(maps.array[3].name.used, 3); + assert_int_equal(maps.array[3].value.used, 6); + assert_int_equal(maps.array[4].name.used, 4); + assert_int_equal(maps.array[4].value.used, 0); + + // Construct NULL terminated strings to perform validation. + for (uint8_t i = 0; i < 5; ++i) { + + { + char buffer[maps.array[i].name.used + 1]; + + memcpy(buffer, maps.array[i].name.string, maps.array[i].name.used); + buffer[maps.array[i].name.used] = 0; + + assert_string_equal(buffer, names[i]); + } + + { + char buffer[maps.array[i].value.used + 1]; + + memcpy(buffer, maps.array[i].value.string, maps.array[i].value.used); + buffer[maps.array[i].value.used] = 0; + + assert_string_equal(buffer, values[i]); + } + } // for + } + + f_string_maps_resize(0, &maps); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_console/tests/unit/c/test-console-environment_process.h b/level_0/f_console/tests/unit/c/test-console-environment_process.h new file mode 100644 index 0000000..35a8e50 --- /dev/null +++ b/level_0/f_console/tests/unit/c/test-console-environment_process.h @@ -0,0 +1,38 @@ +/** + * FLL - Level 0 + * + * Project: Console + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the console project. + */ +#ifndef _TEST__F_console_environment_process_h +#define _TEST__F_console_environment_process_h + +// f_console_environment_process() only returns memory failures. + +/** + * Test that the function returns F_data_not when there are no environment variables. + * + * @see test__f_console_environment_process__data_not() + */ +extern void test__f_console_environment_process__data_not(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_console_environment_process() + */ +#ifndef _di_level_0_parameter_checking_ + extern void test__f_console_environment_process__parameter_checking(void **state); +#endif // _di_level_0_parameter_checking_ + +/** + * Test that function works. + * + * @see f_console_environment_process() + */ +extern void test__f_console_environment_process__works(void **state); + +#endif // _TEST__F_console_environment_process_h diff --git a/level_0/f_console/tests/unit/c/test-console-parameter_process.c b/level_0/f_console/tests/unit/c/test-console-parameter_process.c index 08c706e..e5261c2 100644 --- a/level_0/f_console/tests/unit/c/test-console-parameter_process.c +++ b/level_0/f_console/tests/unit/c/test-console-parameter_process.c @@ -5,92 +5,275 @@ extern "C" { #endif -void test__f_console_parameter_process__no_arguments(void **state) { +void test__f_console_parameter_process__no_arguments_no_program(void **state) { const f_string_t argv[] = { - "program", 0, }; - const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(1, argv); + // Test both a valid and an invalid argc. + for (uint8_t argc = 0; argc < 2; ++argc) { - f_console_parameter_t parameter[] = { - macro_f_console_parameter_t_initialize("f", 0, 0, 1, f_console_type_normal_e), - macro_f_console_parameter_t_initialize("s", "second", 0, 1, f_console_type_normal_e), - macro_f_console_parameter_t_initialize("t", "third", 0, 1, f_console_type_normal_e), - macro_f_console_parameter_t_initialize("F", 0, 0, 0, f_console_type_inverse_e), - macro_f_console_parameter_t_initialize(0, "fifth", 0, 1, f_console_type_inverse_e), - macro_f_console_parameter_t_initialize(0, "sixth", 0, 1, f_console_type_normal_e), - macro_f_console_parameter_t_initialize(0, "seventh", 0, 2, f_console_type_normal_e), - macro_f_console_parameter_t_initialize("N", "not_found", 0, 0, f_console_type_normal_e), - macro_f_console_parameter_t_initialize(0, 0, "other", 0, f_console_type_other_e), - }; + const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, 0); - f_console_parameters_t parameters = macro_f_console_parameters_t_initialize(parameter, 9); + f_console_parameter_t parameter[] = { + macro_f_console_parameter_t_initialize("f", 0, 0, 1, f_console_type_normal_e), + macro_f_console_parameter_t_initialize("s", "second", 0, 1, f_console_type_normal_e), + macro_f_console_parameter_t_initialize("t", "third", 0, 1, f_console_type_normal_e), + macro_f_console_parameter_t_initialize("F", 0, 0, 0, f_console_type_inverse_e), + macro_f_console_parameter_t_initialize(0, "fifth", 0, 1, f_console_type_inverse_e), + macro_f_console_parameter_t_initialize(0, "sixth", 0, 1, f_console_type_normal_e), + macro_f_console_parameter_t_initialize(0, "seventh", 0, 2, f_console_type_normal_e), + macro_f_console_parameter_t_initialize("N", "not_found", 0, 0, f_console_type_normal_e), + macro_f_console_parameter_t_initialize(0, 0, "other", 0, f_console_type_other_e), + }; - { - const f_status_t status = f_console_parameter_process(arguments, ¶meters); + f_console_parameters_t parameters = macro_f_console_parameters_t_initialize(parameter, 9); - assert_int_equal(status, F_none); + { + const f_status_t status = f_console_parameter_process(arguments, ¶meters); + + assert_int_equal(status, F_data_not); + + assert_int_equal(parameter[0].result, f_console_result_none_e); + assert_int_equal(parameter[0].locations.used, 0); + assert_int_equal(parameter[0].values.used, 0); + assert_int_equal(parameter[0].location, 0); + assert_int_equal(parameter[0].location_sub, 0); + + assert_int_equal(parameter[1].result, f_console_result_none_e); + assert_int_equal(parameter[1].locations.used, 0); + assert_int_equal(parameter[1].values.used, 0); + assert_int_equal(parameter[1].location, 0); + assert_int_equal(parameter[1].location_sub, 0); + + assert_int_equal(parameter[2].result, f_console_result_none_e); + assert_int_equal(parameter[2].locations.used, 0); + assert_int_equal(parameter[2].values.used, 0); + assert_int_equal(parameter[2].location, 0); + assert_int_equal(parameter[2].location_sub, 0); + + assert_int_equal(parameter[3].result, f_console_result_none_e); + assert_int_equal(parameter[3].locations.used, 0); + assert_int_equal(parameter[3].values.used, 0); + assert_int_equal(parameter[3].location, 0); + assert_int_equal(parameter[3].location_sub, 0); + + assert_int_equal(parameter[4].result, f_console_result_none_e); + assert_int_equal(parameter[4].locations.used, 0); + assert_int_equal(parameter[4].values.used, 0); + assert_int_equal(parameter[4].location, 0); + assert_int_equal(parameter[4].location_sub, 0); + + assert_int_equal(parameter[5].result, f_console_result_none_e); + assert_int_equal(parameter[5].locations.used, 0); + assert_int_equal(parameter[5].values.used, 0); + assert_int_equal(parameter[5].location, 0); + assert_int_equal(parameter[5].location_sub, 0); + + assert_int_equal(parameter[6].result, f_console_result_none_e); + assert_int_equal(parameter[6].locations.used, 0); + assert_int_equal(parameter[6].values.used, 0); + assert_int_equal(parameter[6].location, 0); + assert_int_equal(parameter[6].location_sub, 0); + + assert_int_equal(parameter[7].result, f_console_result_none_e); + assert_int_equal(parameter[7].locations.used, 0); + assert_int_equal(parameter[7].values.used, 0); + assert_int_equal(parameter[7].location, 0); + assert_int_equal(parameter[7].location_sub, 0); + + assert_int_equal(parameter[8].result, f_console_result_none_e); + assert_int_equal(parameter[8].locations.used, 0); + assert_int_equal(parameter[8].values.used, 0); + assert_int_equal(parameter[8].location, 0); + assert_int_equal(parameter[8].location_sub, 0); + + assert_int_equal(parameters.remaining.used, 0); + } - assert_int_equal(parameter[0].result, f_console_result_none_e); - assert_int_equal(parameter[0].locations.used, 0); - assert_int_equal(parameter[0].values.used, 0); - assert_int_equal(parameter[0].location, 0); - assert_int_equal(parameter[0].location_sub, 0); + f_console_parameters_delete(¶meters); + } // for +} - assert_int_equal(parameter[1].result, f_console_result_none_e); - assert_int_equal(parameter[1].locations.used, 0); - assert_int_equal(parameter[1].values.used, 0); - assert_int_equal(parameter[1].location, 0); - assert_int_equal(parameter[1].location_sub, 0); +void test__f_console_parameter_process__no_arguments(void **state) { - assert_int_equal(parameter[2].result, f_console_result_none_e); - assert_int_equal(parameter[2].locations.used, 0); - assert_int_equal(parameter[2].values.used, 0); - assert_int_equal(parameter[2].location, 0); - assert_int_equal(parameter[2].location_sub, 0); + const f_string_t argv[] = { + "program", + 0, + }; - assert_int_equal(parameter[3].result, f_console_result_none_e); - assert_int_equal(parameter[3].locations.used, 0); - assert_int_equal(parameter[3].values.used, 0); - assert_int_equal(parameter[3].location, 0); - assert_int_equal(parameter[3].location_sub, 0); + // Test both valid and invalid argc. + for (uint8_t argc = 0; argc < 3; ++argc) { - assert_int_equal(parameter[4].result, f_console_result_none_e); - assert_int_equal(parameter[4].locations.used, 0); - assert_int_equal(parameter[4].values.used, 0); - assert_int_equal(parameter[4].location, 0); - assert_int_equal(parameter[4].location_sub, 0); + const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, 0); - assert_int_equal(parameter[5].result, f_console_result_none_e); - assert_int_equal(parameter[5].locations.used, 0); - assert_int_equal(parameter[5].values.used, 0); - assert_int_equal(parameter[5].location, 0); - assert_int_equal(parameter[5].location_sub, 0); + f_console_parameter_t parameter[] = { + macro_f_console_parameter_t_initialize("f", 0, 0, 1, f_console_type_normal_e), + macro_f_console_parameter_t_initialize("s", "second", 0, 1, f_console_type_normal_e), + macro_f_console_parameter_t_initialize("t", "third", 0, 1, f_console_type_normal_e), + macro_f_console_parameter_t_initialize("F", 0, 0, 0, f_console_type_inverse_e), + macro_f_console_parameter_t_initialize(0, "fifth", 0, 1, f_console_type_inverse_e), + macro_f_console_parameter_t_initialize(0, "sixth", 0, 1, f_console_type_normal_e), + macro_f_console_parameter_t_initialize(0, "seventh", 0, 2, f_console_type_normal_e), + macro_f_console_parameter_t_initialize("N", "not_found", 0, 0, f_console_type_normal_e), + macro_f_console_parameter_t_initialize(0, 0, "other", 0, f_console_type_other_e), + }; - assert_int_equal(parameter[6].result, f_console_result_none_e); - assert_int_equal(parameter[6].locations.used, 0); - assert_int_equal(parameter[6].values.used, 0); - assert_int_equal(parameter[6].location, 0); - assert_int_equal(parameter[6].location_sub, 0); + f_console_parameters_t parameters = macro_f_console_parameters_t_initialize(parameter, 9); - assert_int_equal(parameter[7].result, f_console_result_none_e); - assert_int_equal(parameter[7].locations.used, 0); - assert_int_equal(parameter[7].values.used, 0); - assert_int_equal(parameter[7].location, 0); - assert_int_equal(parameter[7].location_sub, 0); + { + const f_status_t status = f_console_parameter_process(arguments, ¶meters); + + assert_int_equal(status, argc ? F_none : F_data_not); + + assert_int_equal(parameter[0].result, f_console_result_none_e); + assert_int_equal(parameter[0].locations.used, 0); + assert_int_equal(parameter[0].values.used, 0); + assert_int_equal(parameter[0].location, 0); + assert_int_equal(parameter[0].location_sub, 0); + + assert_int_equal(parameter[1].result, f_console_result_none_e); + assert_int_equal(parameter[1].locations.used, 0); + assert_int_equal(parameter[1].values.used, 0); + assert_int_equal(parameter[1].location, 0); + assert_int_equal(parameter[1].location_sub, 0); + + assert_int_equal(parameter[2].result, f_console_result_none_e); + assert_int_equal(parameter[2].locations.used, 0); + assert_int_equal(parameter[2].values.used, 0); + assert_int_equal(parameter[2].location, 0); + assert_int_equal(parameter[2].location_sub, 0); + + assert_int_equal(parameter[3].result, f_console_result_none_e); + assert_int_equal(parameter[3].locations.used, 0); + assert_int_equal(parameter[3].values.used, 0); + assert_int_equal(parameter[3].location, 0); + assert_int_equal(parameter[3].location_sub, 0); + + assert_int_equal(parameter[4].result, f_console_result_none_e); + assert_int_equal(parameter[4].locations.used, 0); + assert_int_equal(parameter[4].values.used, 0); + assert_int_equal(parameter[4].location, 0); + assert_int_equal(parameter[4].location_sub, 0); + + assert_int_equal(parameter[5].result, f_console_result_none_e); + assert_int_equal(parameter[5].locations.used, 0); + assert_int_equal(parameter[5].values.used, 0); + assert_int_equal(parameter[5].location, 0); + assert_int_equal(parameter[5].location_sub, 0); + + assert_int_equal(parameter[6].result, f_console_result_none_e); + assert_int_equal(parameter[6].locations.used, 0); + assert_int_equal(parameter[6].values.used, 0); + assert_int_equal(parameter[6].location, 0); + assert_int_equal(parameter[6].location_sub, 0); + + assert_int_equal(parameter[7].result, f_console_result_none_e); + assert_int_equal(parameter[7].locations.used, 0); + assert_int_equal(parameter[7].values.used, 0); + assert_int_equal(parameter[7].location, 0); + assert_int_equal(parameter[7].location_sub, 0); + + assert_int_equal(parameter[8].result, f_console_result_none_e); + assert_int_equal(parameter[8].locations.used, 0); + assert_int_equal(parameter[8].values.used, 0); + assert_int_equal(parameter[8].location, 0); + assert_int_equal(parameter[8].location_sub, 0); + + assert_int_equal(parameters.remaining.used, 0); + } - assert_int_equal(parameter[8].result, f_console_result_none_e); - assert_int_equal(parameter[8].locations.used, 0); - assert_int_equal(parameter[8].values.used, 0); - assert_int_equal(parameter[8].location, 0); - assert_int_equal(parameter[8].location_sub, 0); + f_console_parameters_delete(¶meters); + } // for +} - assert_int_equal(parameters.remaining.used, 0); - } +void test__f_console_parameter_process__null_arguments(void **state) { - f_console_parameters_delete(¶meters); + const f_string_t *argv = 0; + + // Test both a valid and an invalid argc. + for (uint8_t argc = 0; argc < 2; ++argc) { + const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, 0); + + f_console_parameter_t parameter[] = { + macro_f_console_parameter_t_initialize("f", 0, 0, 1, f_console_type_normal_e), + macro_f_console_parameter_t_initialize("s", "second", 0, 1, f_console_type_normal_e), + macro_f_console_parameter_t_initialize("t", "third", 0, 1, f_console_type_normal_e), + macro_f_console_parameter_t_initialize("F", 0, 0, 0, f_console_type_inverse_e), + macro_f_console_parameter_t_initialize(0, "fifth", 0, 1, f_console_type_inverse_e), + macro_f_console_parameter_t_initialize(0, "sixth", 0, 1, f_console_type_normal_e), + macro_f_console_parameter_t_initialize(0, "seventh", 0, 2, f_console_type_normal_e), + macro_f_console_parameter_t_initialize("N", "not_found", 0, 0, f_console_type_normal_e), + macro_f_console_parameter_t_initialize(0, 0, "other", 0, f_console_type_other_e), + }; + + f_console_parameters_t parameters = macro_f_console_parameters_t_initialize(parameter, 9); + + { + const f_status_t status = f_console_parameter_process(arguments, ¶meters); + + assert_int_equal(status, F_data_not); + + assert_int_equal(parameter[0].result, f_console_result_none_e); + assert_int_equal(parameter[0].locations.used, 0); + assert_int_equal(parameter[0].values.used, 0); + assert_int_equal(parameter[0].location, 0); + assert_int_equal(parameter[0].location_sub, 0); + + assert_int_equal(parameter[1].result, f_console_result_none_e); + assert_int_equal(parameter[1].locations.used, 0); + assert_int_equal(parameter[1].values.used, 0); + assert_int_equal(parameter[1].location, 0); + assert_int_equal(parameter[1].location_sub, 0); + + assert_int_equal(parameter[2].result, f_console_result_none_e); + assert_int_equal(parameter[2].locations.used, 0); + assert_int_equal(parameter[2].values.used, 0); + assert_int_equal(parameter[2].location, 0); + assert_int_equal(parameter[2].location_sub, 0); + + assert_int_equal(parameter[3].result, f_console_result_none_e); + assert_int_equal(parameter[3].locations.used, 0); + assert_int_equal(parameter[3].values.used, 0); + assert_int_equal(parameter[3].location, 0); + assert_int_equal(parameter[3].location_sub, 0); + + assert_int_equal(parameter[4].result, f_console_result_none_e); + assert_int_equal(parameter[4].locations.used, 0); + assert_int_equal(parameter[4].values.used, 0); + assert_int_equal(parameter[4].location, 0); + assert_int_equal(parameter[4].location_sub, 0); + + assert_int_equal(parameter[5].result, f_console_result_none_e); + assert_int_equal(parameter[5].locations.used, 0); + assert_int_equal(parameter[5].values.used, 0); + assert_int_equal(parameter[5].location, 0); + assert_int_equal(parameter[5].location_sub, 0); + + assert_int_equal(parameter[6].result, f_console_result_none_e); + assert_int_equal(parameter[6].locations.used, 0); + assert_int_equal(parameter[6].values.used, 0); + assert_int_equal(parameter[6].location, 0); + assert_int_equal(parameter[6].location_sub, 0); + + assert_int_equal(parameter[7].result, f_console_result_none_e); + assert_int_equal(parameter[7].locations.used, 0); + assert_int_equal(parameter[7].values.used, 0); + assert_int_equal(parameter[7].location, 0); + assert_int_equal(parameter[7].location_sub, 0); + + assert_int_equal(parameter[8].result, f_console_result_none_e); + assert_int_equal(parameter[8].locations.used, 0); + assert_int_equal(parameter[8].values.used, 0); + assert_int_equal(parameter[8].location, 0); + assert_int_equal(parameter[8].location_sub, 0); + + assert_int_equal(parameters.remaining.used, 0); + } + + f_console_parameters_delete(¶meters); + } // for } void test__f_console_parameter_process__only_remaining(void **state) { @@ -106,7 +289,7 @@ void test__f_console_parameter_process__only_remaining(void **state) { 0, }; - const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(7, argv); + const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(7, argv, 0); f_console_parameter_t parameter[] = { macro_f_console_parameter_t_initialize("f", 0, 0, 1, f_console_type_normal_e), @@ -224,7 +407,7 @@ void test__f_console_parameter_process__works(void **state) { 0, }; - const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(18, argv); + const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(18, argv, 0); f_console_parameter_t parameter[] = { macro_f_console_parameter_t_initialize("f", 0, 0, 1, f_console_type_normal_e), diff --git a/level_0/f_console/tests/unit/c/test-console-parameter_process.h b/level_0/f_console/tests/unit/c/test-console-parameter_process.h index 68c6b9b..5e9c172 100644 --- a/level_0/f_console/tests/unit/c/test-console-parameter_process.h +++ b/level_0/f_console/tests/unit/c/test-console-parameter_process.h @@ -20,6 +20,20 @@ extern void test__f_console_parameter_process__no_arguments(void **state); /** + * Test that function works with no (argv) arguments and does not have program name. + * + * @see f_console_parameter_process() + */ +extern void test__f_console_parameter_process__no_arguments_no_program(void **state); + +/** + * Test that function works with (argv) arguments as a NULL pointer. + * + * @see f_console_parameter_process() + */ +extern void test__f_console_parameter_process__null_arguments(void **state); + +/** * Test that function works with all (argv) arguments do not match any defined parameter. * * @see f_console_parameter_process() diff --git a/level_0/f_console/tests/unit/c/test-console.c b/level_0/f_console/tests/unit/c/test-console.c index b8267b6..07b59aa 100644 --- a/level_0/f_console/tests/unit/c/test-console.c +++ b/level_0/f_console/tests/unit/c/test-console.c @@ -20,6 +20,10 @@ int main(void) { const struct CMUnitTest tests[] = { + // f_console_environment_process() only returns memory failures. + cmocka_unit_test(test__f_console_environment_process__data_not), + cmocka_unit_test(test__f_console_environment_process__works), + // f_console_identify() doesn't return failure. cmocka_unit_test(test__f_console_identify__works), @@ -30,7 +34,9 @@ int main(void) { cmocka_unit_test(test__f_console_parameter_prioritize_right__works), // f_console_parameter_process() only returns memory failures. + cmocka_unit_test(test__f_console_parameter_process__no_arguments_no_program), cmocka_unit_test(test__f_console_parameter_process__no_arguments), + cmocka_unit_test(test__f_console_parameter_process__null_arguments), cmocka_unit_test(test__f_console_parameter_process__only_remaining), cmocka_unit_test(test__f_console_parameter_process__works), @@ -39,6 +45,7 @@ int main(void) { cmocka_unit_test(test__f_console_parameters_destroy__frees_memory), #ifndef _di_level_0_parameter_checking_ + cmocka_unit_test(test__f_console_environment_process__parameter_checking), cmocka_unit_test(test__f_console_identify__parameter_checking), cmocka_unit_test(test__f_console_parameter_prioritize_left__parameter_checking), cmocka_unit_test(test__f_console_parameter_prioritize_right__parameter_checking), diff --git a/level_0/f_console/tests/unit/c/test-console.h b/level_0/f_console/tests/unit/c/test-console.h index 43f0c93..028e2ee 100644 --- a/level_0/f_console/tests/unit/c/test-console.h +++ b/level_0/f_console/tests/unit/c/test-console.h @@ -24,6 +24,7 @@ // test includes. #include "test-console-identify.h" +#include "test-console-environment_process.h" #include "test-console-parameter_prioritize_left.h" #include "test-console-parameter_prioritize_right.h" #include "test-console-parameter_process.h" diff --git a/level_0/f_string/c/string/common.h b/level_0/f_string/c/string/common.h index 406d52b..f33f52f 100644 --- a/level_0/f_string/c/string/common.h +++ b/level_0/f_string/c/string/common.h @@ -21,7 +21,7 @@ extern "C" { * therefore this gets defined here. */ #ifdef _en_BUG_strnlen_ - extern size_t strnlen (const char *string, size_t max_length); + extern size_t strnlen(const char *string, size_t max_length); #endif // _en_BUG_strnlen_ /** diff --git a/level_0/f_string/c/string/static.c b/level_0/f_string/c/string/static.c new file mode 100644 index 0000000..e69de29 diff --git a/level_0/f_string/c/string/static.h b/level_0/f_string/c/string/static.h new file mode 100644 index 0000000..e69de29 diff --git a/level_3/byte_dump/c/main.c b/level_3/byte_dump/c/main.c index 5f5985a..2ee1992 100644 --- a/level_3/byte_dump/c/main.c +++ b/level_3/byte_dump/c/main.c @@ -1,8 +1,8 @@ #include "byte_dump.h" -int main(const int argc, const f_string_t *argv) { +int main(const int argc, const f_string_t *argv, const f_string_t *envp) { - const f_console_arguments_t arguments = { argc, argv }; + const f_console_arguments_t arguments = { argc, argv, envp }; byte_dump_main_t data = byte_dump_main_t_initialize; if (f_pipe_input_exists()) { diff --git a/level_3/control/c/main.c b/level_3/control/c/main.c index a439f5f..850fd46 100644 --- a/level_3/control/c/main.c +++ b/level_3/control/c/main.c @@ -1,8 +1,8 @@ #include "control.h" -int main(const int argc, const f_string_t *argv) { +int main(const int argc, const f_string_t *argv, const f_string_t *envp) { - const f_console_arguments_t arguments = { argc, argv }; + const f_console_arguments_t arguments = { argc, argv, envp }; fll_program_data_t data = fll_program_data_t_initialize; if (f_pipe_input_exists()) { diff --git a/level_3/controller/c/main.c b/level_3/controller/c/main.c index f91fbfb..4c46e0e 100644 --- a/level_3/controller/c/main.c +++ b/level_3/controller/c/main.c @@ -1,8 +1,8 @@ #include "controller.h" -int main(const int argc, const f_string_t *argv) { +int main(const int argc, const f_string_t *argv, const f_string_t *envp) { - const f_console_arguments_t arguments = { argc, argv }; + const f_console_arguments_t arguments = { argc, argv, envp }; controller_main_t data = controller_main_t_initialize; if (f_pipe_input_exists()) { diff --git a/level_3/fake/c/main.c b/level_3/fake/c/main.c index 1d5665d..06bff78 100644 --- a/level_3/fake/c/main.c +++ b/level_3/fake/c/main.c @@ -14,9 +14,9 @@ * * @see exit() */ -int main(const int argc, const f_string_t *argv) { +int main(const int argc, const f_string_t *argv, const f_string_t *envp) { - const f_console_arguments_t arguments = { argc, argv }; + const f_console_arguments_t arguments = { argc, argv, envp }; fake_main_t data = fake_main_t_initialize; fll_program_standard_setup(&data.signal); diff --git a/level_3/firewall/c/main.c b/level_3/firewall/c/main.c index 66f7f8d..162cec4 100644 --- a/level_3/firewall/c/main.c +++ b/level_3/firewall/c/main.c @@ -1,8 +1,8 @@ #include "firewall.h" -int main(const int argc, const f_string_t *argv) { +int main(const int argc, const f_string_t *argv, const f_string_t *envp) { - const f_console_arguments_t arguments = { argc, argv }; + const f_console_arguments_t arguments = { argc, argv, envp }; firewall_main_t data = firewall_main_t_initialize; if (f_pipe_input_exists()) { diff --git a/level_3/fss_basic_list_read/c/main.c b/level_3/fss_basic_list_read/c/main.c index 29831b8..379cf04 100644 --- a/level_3/fss_basic_list_read/c/main.c +++ b/level_3/fss_basic_list_read/c/main.c @@ -1,6 +1,6 @@ #include "fss_basic_list_read.h" -int main(const int argc, const f_string_t *argv) { +int main(const int argc, const f_string_t *argv, const f_string_t *envp) { f_console_arguments_t arguments = { argc, argv }; fll_program_data_t data = fll_program_data_t_initialize; diff --git a/level_3/fss_basic_list_write/c/main.c b/level_3/fss_basic_list_write/c/main.c index bf62b59..93e6379 100644 --- a/level_3/fss_basic_list_write/c/main.c +++ b/level_3/fss_basic_list_write/c/main.c @@ -1,8 +1,8 @@ #include "fss_basic_list_write.h" -int main(const int argc, const f_string_t *argv) { +int main(const int argc, const f_string_t *argv, const f_string_t *envp) { - const f_console_arguments_t arguments = { argc, argv }; + const f_console_arguments_t arguments = { argc, argv, envp }; fll_program_data_t data = fll_program_data_t_initialize; if (f_pipe_input_exists()) { diff --git a/level_3/fss_basic_read/c/main.c b/level_3/fss_basic_read/c/main.c index 79d532f..7fdb5b6 100644 --- a/level_3/fss_basic_read/c/main.c +++ b/level_3/fss_basic_read/c/main.c @@ -1,6 +1,6 @@ #include "fss_basic_read.h" -int main(const int argc, const f_string_t *argv) { +int main(const int argc, const f_string_t *argv, const f_string_t *envp) { f_console_arguments_t arguments = { argc, argv }; fll_program_data_t data = fll_program_data_t_initialize; diff --git a/level_3/fss_basic_write/c/main.c b/level_3/fss_basic_write/c/main.c index 3e7ab46..aeb2b71 100644 --- a/level_3/fss_basic_write/c/main.c +++ b/level_3/fss_basic_write/c/main.c @@ -1,8 +1,8 @@ #include "fss_basic_write.h" -int main(const int argc, const f_string_t *argv) { +int main(const int argc, const f_string_t *argv, const f_string_t *envp) { - const f_console_arguments_t arguments = { argc, argv }; + const f_console_arguments_t arguments = { argc, argv, envp }; fll_program_data_t data = fll_program_data_t_initialize; if (f_pipe_input_exists()) { diff --git a/level_3/fss_embedded_list_read/c/main.c b/level_3/fss_embedded_list_read/c/main.c index a54f01a..07c341b 100644 --- a/level_3/fss_embedded_list_read/c/main.c +++ b/level_3/fss_embedded_list_read/c/main.c @@ -1,8 +1,8 @@ #include "fss_embedded_list_read.h" -int main(const int argc, const f_string_t *argv) { +int main(const int argc, const f_string_t *argv, const f_string_t *envp) { - const f_console_arguments_t arguments = { argc, argv }; + const f_console_arguments_t arguments = { argc, argv, envp }; fss_embedded_list_read_main_t data = fss_embedded_list_read_main_t_initialize; if (f_pipe_input_exists()) { diff --git a/level_3/fss_embedded_list_write/c/main.c b/level_3/fss_embedded_list_write/c/main.c index ae17ec2..e31d22a 100644 --- a/level_3/fss_embedded_list_write/c/main.c +++ b/level_3/fss_embedded_list_write/c/main.c @@ -1,8 +1,8 @@ #include "fss_embedded_list_write.h" -int main(const int argc, const f_string_t *argv) { +int main(const int argc, const f_string_t *argv, const f_string_t *envp) { - const f_console_arguments_t arguments = { argc, argv }; + const f_console_arguments_t arguments = { argc, argv, envp }; fll_program_data_t data = fll_program_data_t_initialize; if (f_pipe_input_exists()) { diff --git a/level_3/fss_extended_list_read/c/main.c b/level_3/fss_extended_list_read/c/main.c index 5213a2a..2f686c5 100644 --- a/level_3/fss_extended_list_read/c/main.c +++ b/level_3/fss_extended_list_read/c/main.c @@ -1,6 +1,6 @@ #include "fss_extended_list_read.h" -int main(const int argc, const f_string_t *argv) { +int main(const int argc, const f_string_t *argv, const f_string_t *envp) { f_console_arguments_t arguments = { argc, argv }; fll_program_data_t data = fll_program_data_t_initialize; diff --git a/level_3/fss_extended_list_write/c/main.c b/level_3/fss_extended_list_write/c/main.c index 672633e..745ce10 100644 --- a/level_3/fss_extended_list_write/c/main.c +++ b/level_3/fss_extended_list_write/c/main.c @@ -1,8 +1,8 @@ #include "fss_extended_list_write.h" -int main(const int argc, const f_string_t *argv) { +int main(const int argc, const f_string_t *argv, const f_string_t *envp) { - const f_console_arguments_t arguments = { argc, argv }; + const f_console_arguments_t arguments = { argc, argv, envp }; fll_program_data_t data = fll_program_data_t_initialize; if (f_pipe_input_exists()) { diff --git a/level_3/fss_extended_read/c/main.c b/level_3/fss_extended_read/c/main.c index e6ba9bd..2a49383 100644 --- a/level_3/fss_extended_read/c/main.c +++ b/level_3/fss_extended_read/c/main.c @@ -1,6 +1,6 @@ #include "fss_extended_read.h" -int main(const int argc, const f_string_t *argv) { +int main(const int argc, const f_string_t *argv, const f_string_t *envp) { f_console_arguments_t arguments = { argc, argv }; fll_program_data_t data = fll_program_data_t_initialize; diff --git a/level_3/fss_extended_write/c/main.c b/level_3/fss_extended_write/c/main.c index 83662f0..ca3e0ba 100644 --- a/level_3/fss_extended_write/c/main.c +++ b/level_3/fss_extended_write/c/main.c @@ -1,8 +1,8 @@ #include "fss_extended_write.h" -int main(const int argc, const f_string_t *argv) { +int main(const int argc, const f_string_t *argv, const f_string_t *envp) { - const f_console_arguments_t arguments = { argc, argv }; + const f_console_arguments_t arguments = { argc, argv, envp }; fll_program_data_t data = fll_program_data_t_initialize; if (f_pipe_input_exists()) { diff --git a/level_3/fss_identify/c/main.c b/level_3/fss_identify/c/main.c index 5a783e7..cf0b05a 100644 --- a/level_3/fss_identify/c/main.c +++ b/level_3/fss_identify/c/main.c @@ -1,8 +1,8 @@ #include "fss_identify.h" -int main(const int argc, const f_string_t *argv) { +int main(const int argc, const f_string_t *argv, const f_string_t *envp) { - const f_console_arguments_t arguments = { argc, argv }; + const f_console_arguments_t arguments = { argc, argv, envp }; fll_program_data_t data = fll_program_data_t_initialize; if (f_pipe_input_exists()) { diff --git a/level_3/fss_payload_read/c/main.c b/level_3/fss_payload_read/c/main.c index c21cfad..9403fb0 100644 --- a/level_3/fss_payload_read/c/main.c +++ b/level_3/fss_payload_read/c/main.c @@ -1,6 +1,6 @@ #include "fss_payload_read.h" -int main(const int argc, const f_string_t *argv) { +int main(const int argc, const f_string_t *argv, const f_string_t *envp) { f_console_arguments_t arguments = { argc, argv }; fll_program_data_t data = fll_program_data_t_initialize; diff --git a/level_3/fss_payload_write/c/main.c b/level_3/fss_payload_write/c/main.c index 9a3a0a3..be6884f 100644 --- a/level_3/fss_payload_write/c/main.c +++ b/level_3/fss_payload_write/c/main.c @@ -1,8 +1,8 @@ #include "fss_payload_write.h" -int main(const int argc, const f_string_t *argv) { +int main(const int argc, const f_string_t *argv, const f_string_t *envp) { - const f_console_arguments_t arguments = { argc, argv }; + const f_console_arguments_t arguments = { argc, argv, envp }; fll_program_data_t data = fll_program_data_t_initialize; if (f_pipe_input_exists()) { diff --git a/level_3/fss_status_code/c/main.c b/level_3/fss_status_code/c/main.c index 836c447..2b586a9 100644 --- a/level_3/fss_status_code/c/main.c +++ b/level_3/fss_status_code/c/main.c @@ -1,8 +1,8 @@ #include "fss_status_code.h" -int main(const int argc, const f_string_t *argv) { +int main(const int argc, const f_string_t *argv, const f_string_t *envp) { - const f_console_arguments_t arguments = { argc, argv }; + const f_console_arguments_t arguments = { argc, argv, envp }; fll_program_data_t data = fll_program_data_t_initialize; if (f_pipe_input_exists()) { diff --git a/level_3/iki_read/c/main.c b/level_3/iki_read/c/main.c index a3fa352..2e83325 100644 --- a/level_3/iki_read/c/main.c +++ b/level_3/iki_read/c/main.c @@ -1,8 +1,8 @@ #include "iki_read.h" -int main(const int argc, const f_string_t *argv) { +int main(const int argc, const f_string_t *argv, const f_string_t *envp) { - const f_console_arguments_t arguments = { argc, argv }; + const f_console_arguments_t arguments = { argc, argv, envp }; iki_read_main_t data = iki_read_main_t_initialize; if (f_pipe_input_exists()) { diff --git a/level_3/iki_write/c/main.c b/level_3/iki_write/c/main.c index 860a101..c72edd7 100644 --- a/level_3/iki_write/c/main.c +++ b/level_3/iki_write/c/main.c @@ -1,8 +1,8 @@ #include "iki_write.h" -int main(const int argc, const f_string_t *argv) { +int main(const int argc, const f_string_t *argv, const f_string_t *envp) { - const f_console_arguments_t arguments = { argc, argv }; + const f_console_arguments_t arguments = { argc, argv, envp }; iki_write_main_t data = iki_write_main_t_initialize; if (f_pipe_input_exists()) { diff --git a/level_3/status_code/c/main.c b/level_3/status_code/c/main.c index 1d394a7..8e31a82 100644 --- a/level_3/status_code/c/main.c +++ b/level_3/status_code/c/main.c @@ -1,8 +1,8 @@ #include "status_code.h" -int main(const int argc, const f_string_t *argv) { +int main(const int argc, const f_string_t *argv, const f_string_t *envp) { - const f_console_arguments_t arguments = { argc, argv }; + const f_console_arguments_t arguments = { argc, argv, envp }; fll_program_data_t data = fll_program_data_t_initialize; if (f_pipe_input_exists()) { diff --git a/level_3/utf8/c/main.c b/level_3/utf8/c/main.c index a424fe8..2da40a4 100644 --- a/level_3/utf8/c/main.c +++ b/level_3/utf8/c/main.c @@ -1,8 +1,8 @@ #include "utf8.h" -int main(const int argc, const f_string_t *argv) { +int main(const int argc, const f_string_t *argv, const f_string_t *envp) { - const f_console_arguments_t arguments = { argc, argv }; + const f_console_arguments_t arguments = { argc, argv, envp }; fll_program_data_t data = fll_program_data_t_initialize; if (f_pipe_input_exists()) { -- 1.8.3.1