]> Kevux Git Server - fll/commitdiff
Bugfix: invalid read after buffer.
authorKevin Day <thekevinday@gmail.com>
Sat, 18 Jul 2020 05:08:58 +0000 (00:08 -0500)
committerKevin Day <thekevinday@gmail.com>
Sun, 19 Jul 2020 03:21:07 +0000 (22:21 -0500)
If arguments.used was not incremented, then the arguments.used represents the correct position.
If it was incremented, then append that value.

The following string triggered the behavior:
  print Return Code is \"parameter:"return""

level_3/fake/c/private-make.c

index ef2d797c28776b94cc572658c0ea99f1f002b396..ef8071378918bcdf4e1eeac4321244a971abe624 100644 (file)
@@ -646,7 +646,14 @@ extern "C" {
           range.start = iki_variable.array[iki_variable.used - 1].stop + 1;
           range.stop = content.array[i].stop;
 
-          *status = fl_string_dynamic_partial_append_nulless(data_make->buffer, range, &arguments->array[arguments->used]);
+          // if arguments.used was not incremented, then use the value, otherwise arguments.used is past the value to append to, so subtract 1.
+          if (used_arguments == arguments->used) {
+            *status = fl_string_dynamic_partial_append_nulless(data_make->buffer, range, &arguments->array[arguments->used]);
+          }
+          else {
+            *status = fl_string_dynamic_partial_append_nulless(data_make->buffer, range, &arguments->array[arguments->used - 1]);
+          }
+
           if (F_status_is_error(*status)) {
             fake_print_error(data, F_status_set_fine(*status), "fl_string_dynamic_partial_append_nulless", F_true);
             break;