From 088f4a804b7217e6dce73f10c6d65139c76c97f0 Mon Sep 17 00:00:00 2001 From: PenguinKeeper7 Date: Tue, 15 Jul 2025 23:12:02 +0100 Subject: [PATCH] Fix conflict and clean up code --- include/types.h | 8 ++++---- src/user_options.c | 25 +++++++++---------------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/include/types.h b/include/types.h index 5054d1286..19619d42a 100644 --- a/include/types.h +++ b/include/types.h @@ -850,7 +850,7 @@ typedef enum user_options_map IDX_HOOK_THREADS = 0xff1f, IDX_IDENTIFY = 0xff20, IDX_INCREMENT = 'i', - IDX_INCREMENT_INVERSE = 0xff56, + IDX_INCREMENT_INVERSE = 0xff61, IDX_INCREMENT_MAX = 0xff21, IDX_INCREMENT_MIN = 0xff22, IDX_INDUCTION_DIR = 0xff23, @@ -964,9 +964,9 @@ typedef void * hc_dynfunc_t; #endif typedef enum increment { - INCREMENT_NONE, - INCREMENT_NORMAL, - INCREMENT_INVERSED, + INCREMENT_NONE = 0, + INCREMENT_NORMAL = 1, + INCREMENT_INVERSED = 2, } increment_t; /** diff --git a/src/user_options.c b/src/user_options.c index 7e6d65c80..a82305718 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -571,7 +571,7 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) case IDX_BITMAP_MIN: user_options->bitmap_min = hc_strtoul (optarg, NULL, 10); break; case IDX_BITMAP_MAX: user_options->bitmap_max = hc_strtoul (optarg, NULL, 10); break; case IDX_HOOK_THREADS: user_options->hook_threads = hc_strtoul (optarg, NULL, 10); break; - case IDX_INCREMENT: increment_parse(hashcat_ctx); break; + case IDX_INCREMENT: user_options->increment++; break; case IDX_INCREMENT_INVERSE: user_options->increment = INCREMENT_INVERSED; break; case IDX_INCREMENT_MIN: user_options->increment_min = hc_strtoul (optarg, NULL, 10); user_options->increment_min_chgd = true; break; @@ -989,6 +989,14 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) return -1; } + // In case the user uses -iii, escaping enum bounds + if (user_options->increment > INCREMENT_INVERSED) + { + event_log_error (hashcat_ctx, "Invalid -i/--increment value."); + + return -1; + } + if ((user_options->rp_files_cnt > 0) && (user_options->rp_gen > 0)) { event_log_error (hashcat_ctx, "Combining -r/--rules-file and -g/--rules-generate is not supported."); @@ -3387,21 +3395,6 @@ int user_options_check_files (hashcat_ctx_t *hashcat_ctx) return 0; } -void increment_parse (hashcat_ctx_t *hashcat_ctx) -{ - user_options_t *user_options = hashcat_ctx->user_options; - - // Set increment inverse when -ii - if (user_options->increment == INCREMENT_NORMAL) - { - user_options->increment = INCREMENT_INVERSED; - } - else - { - user_options->increment = INCREMENT_NORMAL; - } -} - void user_options_logger (hashcat_ctx_t *hashcat_ctx) { user_options_t *user_options = hashcat_ctx->user_options;