]> Kevux Git Server - fll/commitdiff
Bugfix: When --last is set to 0, entire file is dumped
authorKevin Day <thekevinday@gmail.com>
Sun, 17 Nov 2019 06:58:40 +0000 (00:58 -0600)
committerKevin Day <thekevinday@gmail.com>
Sun, 17 Nov 2019 06:58:40 +0000 (00:58 -0600)
The --last value being set to 0 is internally used to represent entire file.
Explicitly setting --last to 0 makes no sense, so set the minimum allowed size for --last to 1.

level_3/byte_dump/c/byte_dump.c

index cda6533a95b38b4dbd5c7cb6841cd56759c525e0..5bdc72459e9f6b5d70083cff6c2b25d26c0e6103 100644 (file)
@@ -219,11 +219,11 @@ extern "C" {
         f_number_unsigned number = 0;
         status = fl_console_parameter_to_number_unsigned(arguments.argv[data->parameters[byte_dump_parameter_last].additional.array[data->parameters[byte_dump_parameter_last].additional.used - 1]], &number);
 
-        if (f_status_is_error(status) || number > f_type_number_size_unsigned) {
+        if (f_status_is_error(status) || number < 1 || number > f_type_number_size_unsigned) {
           fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '");
           fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", byte_dump_long_last);
           fl_color_print(f_standard_error, data->context.error, data->context.reset, "' value can only be a number (inclusively) between ");
-          fl_color_print(f_standard_error, data->context.notable, data->context.reset, "0");
+          fl_color_print(f_standard_error, data->context.notable, data->context.reset, "1");
           fl_color_print(f_standard_error, data->context.error, data->context.reset, " and ");
           fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%llu", f_type_number_size_unsigned);
           fl_color_print_line(f_standard_error, data->context.error, data->context.reset, ".");