]> Kevux Git Server - fll/commitdiff
Update: use firewall_default_allocation_step, +1 was being used and should have been...
authorKevin Day <thekevinday@gmail.com>
Tue, 17 Mar 2015 02:41:03 +0000 (21:41 -0500)
committerKevin Day <thekevinday@gmail.com>
Tue, 17 Mar 2015 02:41:03 +0000 (21:41 -0500)
level_3/firewall/c/private-firewall.c

index dcfe0df2604b26a9812fa1acd1cb83bc22aed7fc..09d73922551cd103f26751a496b8d6025c9b3110 100644 (file)
       for (r = repeat; r > 0; r--) {
         // first add the program name
         f_delete_dynamic_strings(status, arguments);
-        f_resize_dynamic_strings(status, arguments, arguments.used + 1);
+        f_resize_dynamic_strings(status, arguments, arguments.used + firewall_default_allocation_step);
 
         if (f_error_is_error(status)) break;
 
           }
 
           if (argument.used > 0) {
-            f_resize_dynamic_strings(status, arguments, arguments.used + 1);
+            f_resize_dynamic_strings(status, arguments, arguments.used + firewall_default_allocation_step);
 
             if (f_error_is_error(status)) break;
 
             }
 
             if (argument.used > 0) {
-              f_resize_dynamic_strings(status, arguments, arguments.used + 1);
+              f_resize_dynamic_strings(status, arguments, arguments.used + firewall_default_allocation_step);
 
               if (f_error_is_error(status)) break;
 
             }
 
             if (argument.used > 0) {
-              f_resize_dynamic_strings(status, arguments, arguments.used + 1);
+              f_resize_dynamic_strings(status, arguments, arguments.used + firewall_default_allocation_step);
 
               if (f_error_is_error(status)) break;
 
           argument.used = device.used;
 
           if (argument.used > 0) {
-            f_resize_dynamic_strings(status, arguments, arguments.used + 1);
+            f_resize_dynamic_strings(status, arguments, arguments.used + firewall_default_allocation_step);
 
             if (f_error_is_error(status)) break;
 
           argument.used = firewall_protocol_command_length;
 
           if (argument.used > 0) {
-            f_resize_dynamic_strings(status, arguments, arguments.used + 1);
+            f_resize_dynamic_strings(status, arguments, arguments.used + firewall_default_allocation_step);
+
             if (f_error_is_error(status)) break;
 
             arguments.array[arguments.used].string = argument.string;
           argument.used = protocol.used;
 
           if (argument.used > 0) {
-            f_resize_dynamic_strings(status, arguments, arguments.used + 1);
+            f_resize_dynamic_strings(status, arguments, arguments.used + firewall_default_allocation_step);
 
             if (f_error_is_error(status)) break;
 
             length = (local.rule_contents.array[i].array[subcounter].stop - local.rule_contents.array[i].array[subcounter].start) + 1;
 
             if (length > 0) {
-              f_resize_dynamic_string(status, ip_list, length);
+              f_resize_dynamic_string(status, ip_list, (local.rule_contents.array[i].array[subcounter].stop - local.rule_contents.array[i].array[subcounter].start) + firewall_default_allocation_step);
 
               if (f_error_is_error(status)) {
                 subcounter = local.rule_contents.array[i].used;
             length = (local.rule_contents.array[i].array[subcounter].stop - local.rule_contents.array[i].array[subcounter].start) + 1;
 
             if (length > 0) {
-              f_resize_dynamic_string(status, argument, length);
+              f_resize_dynamic_string(status, argument, (local.rule_contents.array[i].array[subcounter].stop - local.rule_contents.array[i].array[subcounter].start) + firewall_default_allocation_step);
 
               if (f_error_is_error(status)) break;
 
             argument.used = length;
 
             if (length > 0) {
-              f_resize_dynamic_strings(status, arguments, arguments.used + 1);
+              f_resize_dynamic_strings(status, arguments, arguments.used + firewall_default_allocation_step);
 
               if (f_error_is_error(status)) break;
 
             f_fss_objects  basic_objects  = f_fss_objects_initialize;
             f_fss_contents basic_contents = f_fss_objects_initialize;
 
-            f_resize_dynamic_string(status, file_path, network_path_length + ip_list.used + 1);
+            f_resize_dynamic_string(status, file_path, network_path_length + ip_list.used + firewall_default_allocation_step);
 
             if (status == f_none) {
               strncat(file_path.string, network_path, network_path_length);
                   f_dynamic_string ip_list_action = f_dynamic_string_initialize;
 
                   if (ip_list_direction) {
-                    f_resize_dynamic_string(status, ip_list_action, firewall_ip_list_destination_action_length + 1);
+                    f_resize_dynamic_string(status, ip_list_action, firewall_ip_list_destination_action_length + firewall_default_allocation_step);
                     strncat(ip_list_action.string, firewall_ip_list_destination_action, firewall_ip_list_destination_action_length);
                   } else {
-                    f_resize_dynamic_string(status, ip_list_action, firewall_ip_list_source_action_length + 1);
+                    f_resize_dynamic_string(status, ip_list_action, firewall_ip_list_source_action_length + firewall_default_allocation_step);
                     strncat(ip_list_action.string, firewall_ip_list_source_action, firewall_ip_list_source_action_length);
                   }
 
                       for (; buffer_counter < basic_objects.used; buffer_counter++) {
                         ip_length = (basic_objects.array[buffer_counter].stop - basic_objects.array[buffer_counter].start) + 1;
 
-                        f_resize_dynamic_string(status, ip_argument, ip_length);
+                        f_resize_dynamic_string(status, ip_argument, (basic_objects.array[buffer_counter].stop - basic_objects.array[buffer_counter].start) + firewall_default_allocation_step);
 
                         if (f_error_is_error(status)) {
                           fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory");
         length = local->chain_objects.array[i].stop - local->chain_objects.array[i].start + 1;
 
         if (data->chains.used >= data->chains.size) {
-          f_resize_dynamic_strings(status, data->chains, data->chains.used + firewall_default_allocation_step);
+          f_resize_dynamic_strings(status, data->chains, (local->chain_objects.array[i].stop - local->chain_objects.array[i].start + firewall_default_allocation_step);
 
           if (f_error_is_error(status)) {
             f_delete_dynamic_strings(status2, arguments);