]> Kevux Git Server - fll/commitdiff
Security: fix memory leaks in FSS read programs
authorKevin Day <thekevinday@gmail.com>
Fri, 28 Feb 2020 04:30:54 +0000 (22:30 -0600)
committerKevin Day <thekevinday@gmail.com>
Fri, 28 Feb 2020 05:10:47 +0000 (23:10 -0600)
level_3/fss_basic_list_read/c/fss_basic_list_read.c
level_3/fss_basic_read/c/fss_basic_read.c
level_3/fss_extended_list_read/c/fss_extended_list_read.c
level_3/fss_extended_read/c/fss_extended_read.c

index 9fb0867bbac1c4285433b0804465b21970f7ffb0..64d8412494c68a21a7920cc7abbb8e725077fa86 100644 (file)
@@ -145,6 +145,7 @@ extern "C" {
         fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_basic_list_read_long_at);
         fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number.");
 
+        fss_basic_list_read_delete_data(data);
         return f_status_set_error(f_invalid_parameter);
       }
 
@@ -153,6 +154,7 @@ extern "C" {
         fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_basic_list_read_long_depth);
         fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number.");
 
+        fss_basic_list_read_delete_data(data);
         return f_status_set_error(f_invalid_parameter);
       }
 
@@ -161,6 +163,7 @@ extern "C" {
         fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_basic_list_read_long_line);
         fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number.");
 
+        fss_basic_list_read_delete_data(data);
         return f_status_set_error(f_invalid_parameter);
       }
 
@@ -169,6 +172,7 @@ extern "C" {
         fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_basic_list_read_long_name);
         fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a string.");
 
+        fss_basic_list_read_delete_data(data);
         return f_status_set_error(f_invalid_parameter);
       }
 
@@ -177,6 +181,7 @@ extern "C" {
         fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_basic_list_read_long_select);
         fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number.");
 
+        fss_basic_list_read_delete_data(data);
         return f_status_set_error(f_invalid_parameter);
       }
 
@@ -188,6 +193,7 @@ extern "C" {
           fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_basic_list_read_long_line);
           fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' parameter.");
 
+          fss_basic_list_read_delete_data(data);
           return f_status_set_error(f_invalid_parameter);
         }
 
@@ -198,6 +204,7 @@ extern "C" {
           fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_basic_list_read_long_select);
           fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' parameter.");
 
+          fss_basic_list_read_delete_data(data);
           return f_status_set_error(f_invalid_parameter);
         }
       }
@@ -210,6 +217,7 @@ extern "C" {
           fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_basic_list_read_long_total);
           fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' parameter.");
 
+          fss_basic_list_read_delete_data(data);
           return f_status_set_error(f_invalid_parameter);
         }
       }
@@ -228,11 +236,16 @@ extern "C" {
 
       // This standard does not support nesting, so any depth greater than 0 can be predicted without processing the file.
       if (depths.array[0].depth > 0) {
+        macro_fss_basic_list_read_depths_delete_simple(depths);
+
         if (data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found) {
           fprintf(f_standard_output, "0%c", f_string_eol);
+
+          fss_basic_list_read_delete_data(data);
           return f_none;
         }
 
+        fss_basic_list_read_delete_data(data);
         return f_none;
       }
 
@@ -240,6 +253,9 @@ extern "C" {
         fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: the '");
         fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_basic_list_read_long_select);
         fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' parameter requires a positive number.");
+
+        macro_fss_basic_list_read_depths_delete_simple(depths);
+        fss_basic_list_read_delete_data(data);
         return f_status_set_error(f_invalid_parameter);
       }
 
@@ -252,6 +268,7 @@ extern "C" {
 
         if (f_status_is_error(status)) {
           fss_basic_list_read_print_file_error(data->context, "fl_file_read_fifo", "-", f_status_set_fine(status));
+
           macro_fss_basic_list_read_depths_delete_simple(depths);
           fss_basic_list_read_delete_data(data);
           return status;
index 695bd298bbd30c922df01ee55cf4c56811bef01e..28a4b21fc0b00ba3d06b651260b25331035f066d 100644 (file)
@@ -145,6 +145,7 @@ extern "C" {
         fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_basic_read_long_at);
         fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number.");
 
+        fss_basic_read_delete_data(data);
         return f_status_set_error(f_invalid_parameter);
       }
 
@@ -153,6 +154,7 @@ extern "C" {
         fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_basic_read_long_depth);
         fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number.");
 
+        fss_basic_read_delete_data(data);
         return f_status_set_error(f_invalid_parameter);
       }
 
@@ -161,6 +163,7 @@ extern "C" {
         fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_basic_read_long_line);
         fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number.");
 
+        fss_basic_read_delete_data(data);
         return f_status_set_error(f_invalid_parameter);
       }
 
@@ -169,6 +172,7 @@ extern "C" {
         fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_basic_read_long_name);
         fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a string.");
 
+        fss_basic_read_delete_data(data);
         return f_status_set_error(f_invalid_parameter);
       }
 
@@ -177,6 +181,7 @@ extern "C" {
         fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_basic_read_long_select);
         fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number.");
 
+        fss_basic_read_delete_data(data);
         return f_status_set_error(f_invalid_parameter);
       }
 
@@ -188,6 +193,7 @@ extern "C" {
           fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_basic_read_long_line);
           fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' parameter.");
 
+          fss_basic_read_delete_data(data);
           return f_status_set_error(f_invalid_parameter);
         }
 
@@ -198,6 +204,7 @@ extern "C" {
           fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_basic_read_long_select);
           fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' parameter.");
 
+          fss_basic_read_delete_data(data);
           return f_status_set_error(f_invalid_parameter);
         }
       }
@@ -210,6 +217,7 @@ extern "C" {
           fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_basic_read_long_total);
           fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' parameter.");
 
+          fss_basic_read_delete_data(data);
           return f_status_set_error(f_invalid_parameter);
         }
       }
@@ -228,11 +236,16 @@ extern "C" {
 
       // This standard does not support nesting, so any depth greater than 0 can be predicted without processing the file.
       if (depths.array[0].depth > 0) {
+        macro_fss_basic_read_depths_delete_simple(depths);
+
         if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found) {
           fprintf(f_standard_output, "0%c", f_string_eol);
+
+          fss_basic_read_delete_data(data);
           return f_none;
         }
 
+        fss_basic_read_delete_data(data);
         return f_none;
       }
 
@@ -240,6 +253,9 @@ extern "C" {
         fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: the '");
         fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_basic_read_long_select);
         fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' parameter requires a positive number.");
+
+        macro_fss_basic_read_depths_delete_simple(depths);
+        fss_basic_read_delete_data(data);
         return f_status_set_error(f_invalid_parameter);
       }
 
@@ -252,6 +268,7 @@ extern "C" {
 
         if (f_status_is_error(status)) {
           fss_basic_read_print_file_error(data->context, "fl_file_read_fifo", "-", f_status_set_fine(status));
+
           macro_fss_basic_read_depths_delete_simple(depths);
           fss_basic_read_delete_data(data);
           return status;
@@ -281,6 +298,7 @@ extern "C" {
 
           if (f_status_is_error(status)) {
             fss_basic_read_print_file_error(data->context, "f_file_open", arguments.argv[data->remaining.array[counter]], f_status_set_fine(status));
+
             macro_fss_basic_read_depths_delete_simple(depths);
             fss_basic_read_delete_data(data);
             return status;
@@ -306,6 +324,7 @@ extern "C" {
 
           if (f_status_is_error(status)) {
             fss_basic_read_print_file_error(data->context, "fl_file_read", arguments.argv[data->remaining.array[counter]], f_status_set_fine(status));
+
             macro_fss_basic_read_depths_delete_simple(depths);
             fss_basic_read_delete_data(data);
             return status;
index b572efd57129a7f11fe285c899d291ca3f730764..1f7b005a1f75c9227d92900e346c34b52e3e381d 100644 (file)
@@ -145,6 +145,7 @@ extern "C" {
         fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_extended_list_read_long_at);
         fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number.");
 
+        fss_extended_list_read_delete_data(data);
         return f_status_set_error(f_invalid_parameter);
       }
 
@@ -153,6 +154,7 @@ extern "C" {
         fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_extended_list_read_long_depth);
         fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number.");
 
+        fss_extended_list_read_delete_data(data);
         return f_status_set_error(f_invalid_parameter);
       }
 
@@ -161,6 +163,7 @@ extern "C" {
         fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_extended_list_read_long_line);
         fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number.");
 
+        fss_extended_list_read_delete_data(data);
         return f_status_set_error(f_invalid_parameter);
       }
 
@@ -169,6 +172,7 @@ extern "C" {
         fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_extended_list_read_long_name);
         fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a string.");
 
+        fss_extended_list_read_delete_data(data);
         return f_status_set_error(f_invalid_parameter);
       }
 
@@ -177,6 +181,7 @@ extern "C" {
         fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_extended_list_read_long_select);
         fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number.");
 
+        fss_extended_list_read_delete_data(data);
         return f_status_set_error(f_invalid_parameter);
       }
 
@@ -188,6 +193,7 @@ extern "C" {
           fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_extended_list_read_long_line);
           fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' parameter.");
 
+          fss_extended_list_read_delete_data(data);
           return f_status_set_error(f_invalid_parameter);
         }
 
@@ -198,6 +204,7 @@ extern "C" {
           fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_extended_list_read_long_select);
           fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' parameter.");
 
+          fss_extended_list_read_delete_data(data);
           return f_status_set_error(f_invalid_parameter);
         }
       }
@@ -210,6 +217,7 @@ extern "C" {
           fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_extended_list_read_long_total);
           fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' parameter.");
 
+          fss_extended_list_read_delete_data(data);
           return f_status_set_error(f_invalid_parameter);
         }
       }
@@ -230,6 +238,9 @@ extern "C" {
         fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: the '");
         fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_extended_list_read_long_select);
         fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' parameter requires a positive number.");
+
+        macro_fss_extended_list_read_depths_delete_simple(depths);
+        fss_extended_list_read_delete_data(data);
         return f_status_set_error(f_invalid_parameter);
       }
 
@@ -242,6 +253,7 @@ extern "C" {
 
         if (f_status_is_error(status)) {
           fss_extended_list_read_print_file_error(data->context, "fl_file_read_fifo", "-", f_status_set_fine(status));
+
           macro_fss_extended_list_read_depths_delete_simple(depths);
           fss_extended_list_read_delete_data(data);
           return status;
@@ -270,6 +282,7 @@ extern "C" {
 
           if (f_status_is_error(status)) {
             fss_extended_list_read_print_file_error(data->context, "f_file_open", arguments.argv[data->remaining.array[counter]], f_status_set_fine(status));
+
             macro_fss_extended_list_read_depths_delete_simple(depths);
             fss_extended_list_read_delete_data(data);
             return status;
@@ -295,6 +308,7 @@ extern "C" {
 
           if (f_status_is_error(status)) {
             fss_extended_list_read_print_file_error(data->context, "fl_file_read", arguments.argv[data->remaining.array[counter]], f_status_set_fine(status));
+
             macro_fss_extended_list_read_depths_delete_simple(depths);
             fss_extended_list_read_delete_data(data);
             return status;
index b38c757e3c8f9b6d2dbc0611864b34fc2ace0a6c..b8dadd8272642e6329e15a252e34c6cf5f112015 100644 (file)
@@ -145,6 +145,7 @@ extern "C" {
         fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_extended_read_long_at);
         fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number.");
 
+        fss_extended_read_delete_data(data);
         return f_status_set_error(f_invalid_parameter);
       }
 
@@ -153,6 +154,7 @@ extern "C" {
         fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_extended_read_long_depth);
         fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number.");
 
+        fss_extended_read_delete_data(data);
         return f_status_set_error(f_invalid_parameter);
       }
 
@@ -161,6 +163,7 @@ extern "C" {
         fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_extended_read_long_line);
         fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number.");
 
+        fss_extended_read_delete_data(data);
         return f_status_set_error(f_invalid_parameter);
       }
 
@@ -169,6 +172,7 @@ extern "C" {
         fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_extended_read_long_name);
         fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a string.");
 
+        fss_extended_read_delete_data(data);
         return f_status_set_error(f_invalid_parameter);
       }
 
@@ -177,6 +181,7 @@ extern "C" {
         fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_extended_read_long_select);
         fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number.");
 
+        fss_extended_read_delete_data(data);
         return f_status_set_error(f_invalid_parameter);
       }
 
@@ -188,6 +193,7 @@ extern "C" {
           fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_extended_read_long_line);
           fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' parameter.");
 
+          fss_extended_read_delete_data(data);
           return f_status_set_error(f_invalid_parameter);
         }
 
@@ -198,6 +204,7 @@ extern "C" {
           fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_extended_read_long_select);
           fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' parameter.");
 
+          fss_extended_read_delete_data(data);
           return f_status_set_error(f_invalid_parameter);
         }
       }
@@ -210,6 +217,7 @@ extern "C" {
           fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_extended_read_long_total);
           fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' parameter.");
 
+          fss_extended_read_delete_data(data);
           return f_status_set_error(f_invalid_parameter);
         }
       }
@@ -228,11 +236,16 @@ extern "C" {
 
       // This standard does not support nesting, so any depth greater than 0 can be predicted without processing the file.
       if (depths.array[0].depth > 0) {
+        macro_fss_extended_read_depths_delete_simple(depths);
+
         if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found) {
           fprintf(f_standard_output, "0%c", f_string_eol);
+
+          fss_extended_read_delete_data(data);
           return f_none;
         }
 
+        fss_extended_read_delete_data(data);
         return f_none;
       }
 
@@ -240,6 +253,9 @@ extern "C" {
         fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: the '");
         fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_extended_read_long_select);
         fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' parameter requires a positive number.");
+
+        macro_fss_extended_read_depths_delete_simple(depths);
+        fss_extended_read_delete_data(data);
         return f_status_set_error(f_invalid_parameter);
       }
 
@@ -252,6 +268,7 @@ extern "C" {
 
         if (f_status_is_error(status)) {
           fss_extended_read_print_file_error(data->context, "fl_file_read_fifo", "-", f_status_set_fine(status));
+
           macro_fss_extended_read_depths_delete_simple(depths);
           fss_extended_read_delete_data(data);
           return status;
@@ -281,6 +298,7 @@ extern "C" {
 
           if (f_status_is_error(status)) {
             fss_extended_read_print_file_error(data->context, "f_file_open", arguments.argv[data->remaining.array[counter]], f_status_set_fine(status));
+
             macro_fss_extended_read_depths_delete_simple(depths);
             fss_extended_read_delete_data(data);
             return status;
@@ -306,6 +324,7 @@ extern "C" {
 
           if (f_status_is_error(status)) {
             fss_extended_read_print_file_error(data->context, "fl_file_read", arguments.argv[data->remaining.array[counter]], f_status_set_fine(status));
+
             macro_fss_extended_read_depths_delete_simple(depths);
             fss_extended_read_delete_data(data);
             return status;