From 9ef981a20f36eb8a6401c73ff5347c82792330f6 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sat, 9 Jul 2022 22:28:12 -0500 Subject: [PATCH] Bugfix: Empty strings improperly pass validation checks. An operation such as the following: if exists 'define:"does_not_exist"' Results in an empty string. The empty string is passing the existence check. Empty strings should fail existence checks in this case. Handle all such cases that I am able to quickly find. --- level_3/fake/c/private-make-operate_process_type.c | 26 ++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/level_3/fake/c/private-make-operate_process_type.c b/level_3/fake/c/private-make-operate_process_type.c index 16a8589..1a5c9af 100644 --- a/level_3/fake/c/private-make-operate_process_type.c +++ b/level_3/fake/c/private-make-operate_process_type.c @@ -57,7 +57,7 @@ extern "C" { return F_status_set_error(F_failure); } - if (status == F_false || status == F_file_found_not) { + if (status == F_false || status == F_file_found_not || status == F_data_not) { existing = F_false; } } @@ -361,6 +361,17 @@ extern "C" { f_array_length_t i = if_not ? 2 : 1; bool dereference = F_true; + if (i == arguments.used) { + if (if_not) { + state_process->condition_result = fake_condition_result_true_e; + } + else { + state_process->condition_result = fake_condition_result_false_e; + } + + return F_none; + } + state_process->condition_result = fake_condition_result_true_e; if (fl_string_dynamic_compare(fake_make_operation_argument_no_dereference_s, arguments.array[i]) == F_equal_to) { @@ -388,7 +399,7 @@ extern "C" { } } else { - if (status == F_false) { + if (status != F_true) { state_process->condition_result = fake_condition_result_false_e; break; @@ -421,6 +432,17 @@ extern "C" { dereference = F_false; } + if (i == arguments.used) { + if (if_not) { + state_process->condition_result = fake_condition_result_true_e; + } + else { + state_process->condition_result = fake_condition_result_false_e; + } + + return F_none; + } + status = F_none; for (; i < arguments.used; ++i) { -- 1.8.3.1