From 721e1ea54d74a408cf6520fd1d0425a4a91f56af Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Wed, 8 Sep 2021 17:37:18 +0200 Subject: [PATCH] Fixed division by zero because backend_ctx->hardware_power_all was not re-inserted after refactoring device_param->hardware_power --- docs/changes.txt | 1 + src/backend.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index 2292050d2..fabd05755 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -4,6 +4,7 @@ ## Bugs ## +- Fixed division by zero because backend_ctx->hardware_power_all was not re-inserted after refactoring device_param->hardware_power - Fixed invalid progress counter initialization in attack-mode 9 when using --skip or --restore - Fixed out-of-boundary reads in attack-mode 9 that were caused by a missing work item limit in the refactored autotune engine diff --git a/src/backend.c b/src/backend.c index d7c6e7f89..34c843715 100644 --- a/src/backend.c +++ b/src/backend.c @@ -10725,6 +10725,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) u64 size_total_host_all = 0; + u32 hardware_power_all = 0; + for (int backend_devices_idx = 0; backend_devices_idx < backend_ctx->backend_devices_cnt; backend_devices_idx++) { /** @@ -15082,9 +15084,18 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) } } + hardware_power_all += hardware_power_max; + EVENT_DATA (EVENT_BACKEND_DEVICE_INIT_POST, &backend_devices_idx, sizeof (int)); } + if (user_options->benchmark == false) + { + if (hardware_power_all == 0) return -1; + } + + backend_ctx->hardware_power_all = hardware_power_all; + EVENT_DATA (EVENT_BACKEND_SESSION_HOSTMEM, &size_total_host_all, sizeof (u64)); return 0; @@ -15578,7 +15589,6 @@ void backend_session_reset (hashcat_ctx_t *hashcat_ctx) device_param->hardware_power = 0; } - backend_ctx->hardware_power_all = 0; backend_ctx->kernel_power_all = 0; backend_ctx->kernel_power_final = 0; }