]> Kevux Git Server - fll/commitdiff
Bugfix: Invalid read because NULL is added to list but then f_string_dynamic_append_n...
authorKevin Day <thekevinday@gmail.com>
Wed, 16 Feb 2022 00:53:25 +0000 (18:53 -0600)
committerKevin Day <thekevinday@gmail.com>
Wed, 16 Feb 2022 00:53:25 +0000 (18:53 -0600)
The NULL doesn't matter if the function being called specifically ignores it.
This mistake causes invalid memory reads.

level_3/fake/c/private-make-load_fakefile.c

index 22b189253be946ce8c74c160209d30dac01013b8..a775669ab3e8d2426b8fe0fa31b8a6ac01083ad1 100644 (file)
@@ -534,8 +534,15 @@ extern "C" {
             break;
           }
 
-          // Include the terminating NULL when copying.
-          ++name_define.used;
+          data_make->setting_build.environment.array[data_make->setting_build.environment.used].used = 0;
+
+          status = f_string_dynamic_increase_by(name_define.used + 1, &data_make->setting_build.environment.array[data_make->setting_build.environment.used]);
+
+          if (F_status_is_error(status)) {
+            fll_error_print(data_make->main->error, F_status_set_fine(status), "f_string_dynamic_increase_by", F_true);
+
+            break;
+          }
 
           status = f_string_dynamic_append_nulless(name_define, &data_make->setting_build.environment.array[data_make->setting_build.environment.used]);
 
@@ -545,8 +552,15 @@ extern "C" {
             break;
           }
 
-          // Set the terminating NULL to not being normally included.
-          --data_make->setting_build.environment.array[data_make->setting_build.environment.used++].used;
+          status = f_string_dynamic_terminate_after(&data_make->setting_build.environment.array[data_make->setting_build.environment.used]);
+
+          if (F_status_is_error(status)) {
+            fll_error_print(data_make->main->error, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true);
+
+            break;
+          }
+
+          ++data_make->setting_build.environment.used;
         }
         else if (data_make->main->warning.verbosity == f_console_verbosity_verbose_e) {
           flockfile(data_make->main->warning.to.stream);