From 7398b03be30b45d1e89dd7b7ec7799ee5d5b0f52 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Thu, 24 Oct 2024 20:15:08 +0200 Subject: [PATCH] User Options: limit --bitmap-max value to 31 --- docs/changes.txt | 1 + src/bitmap.c | 2 ++ src/usage.c | 2 +- src/user_options.c | 7 +++++++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index 283e3c0d4..ef9be50bb 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -130,6 +130,7 @@ - Metal Backend: allow use of devices with Metal if runtime version is >= 200 - Metal Backend: disable Metal devices only if at least one OpenCL device is active - User Options: added --metal-compiler-runtime option +- User Options: limit --bitmap-max value to 31 - Hardware Monitor: avoid sprintf in src/ext_iokit.c - Help: show supported hash-modes only with -hh - Makefile: prevent make failure with Apple Silicon in case of partial rebuild diff --git a/src/bitmap.c b/src/bitmap.c index 367b16a7c..12f701fe5 100644 --- a/src/bitmap.c +++ b/src/bitmap.c @@ -110,6 +110,8 @@ int bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx) u32 *bitmap_s2_c = (u32 *) hcmalloc ((1U << bitmap_max) * sizeof (u32)); u32 *bitmap_s2_d = (u32 *) hcmalloc ((1U << bitmap_max) * sizeof (u32)); + if (!bitmap_s1_a || !bitmap_s1_b || !bitmap_s1_c || !bitmap_s1_d || !bitmap_s2_a || !bitmap_s2_b || !bitmap_s2_c || !bitmap_s2_d) return -1; + u32 bitmap_bits; u32 bitmap_nums; u32 bitmap_mask; diff --git a/src/usage.c b/src/usage.c index 7cbf22348..1bee7c547 100644 --- a/src/usage.c +++ b/src/usage.c @@ -91,7 +91,7 @@ static const char *const USAGE_BIG_PRE_HASHMODES[] = " --progress-only | | Return ideal progress step size and time to process |", " -c, --segment-size | Num | Sets size in MB to cache from the wordfile to X | -c 32", " --bitmap-min | Num | Sets minimum bits allowed for bitmaps to X | --bitmap-min=24", - " --bitmap-max | Num | Sets maximum bits allowed for bitmaps to X | --bitmap-max=24", + " --bitmap-max | Num | Sets maximum bits allowed for bitmaps to X (max: 31) | --bitmap-max=24", " --cpu-affinity | Str | Locks to CPU devices, separated with commas | --cpu-affinity=1,2,3", " --hook-threads | Num | Sets number of threads for a hook (per compute unit) | --hook-threads=8", " --hash-info | | Show information for each hash-mode |", diff --git a/src/user_options.c b/src/user_options.c index b1ed588f4..1bf346d13 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -945,6 +945,13 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) return -1; } + if (user_options->bitmap_max > 31) + { + event_log_error (hashcat_ctx, "Invalid --bitmap-max value specified - must be lower than 32."); + + return -1; + } + if (user_options->rp_gen_func_min > user_options->rp_gen_func_max) { event_log_error (hashcat_ctx, "Invalid --rp-gen-func-min value specified.");