From 82457d290469db2b125e6ae3ebcc922aaf7f9235 Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 10 Jul 2018 13:17:07 +0200 Subject: [PATCH] Fixed a missing check for errors on OpenCL device leading to invalid removal of restore file --- docs/changes.txt | 1 + include/types.h | 1 + src/dispatch.c | 18 ++++++++++++++++-- src/hashcat.c | 2 ++ src/status.c | 2 ++ 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 6d80927af..f92831f3d 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -23,6 +23,7 @@ - Fixed a missing kernel in -m 5600 in combination with -a 3 and -O if mask is >= 16 characters - Fixed a miscalculation in --progress-only mode output for extreme slow kernels like -m 14800 - Fixed missing code section in -m 2500 and -m 2501 to crack corrupted handshakes with a LE endian bitness base +- Fixed a missing check for errors on OpenCL device leading to invalid removal of restore file * changes v4.0.1 -> v4.1.0 diff --git a/include/types.h b/include/types.h index 09a49a34d..3f0f0256e 100644 --- a/include/types.h +++ b/include/types.h @@ -177,6 +177,7 @@ typedef enum status_rc STATUS_BYPASS = 9, STATUS_ABORTED_CHECKPOINT = 10, STATUS_ABORTED_RUNTIME = 11, + STATUS_ERROR = 13, } status_rc_t; diff --git a/src/dispatch.c b/src/dispatch.c index 4f0170a01..5e69e34cf 100644 --- a/src/dispatch.c +++ b/src/dispatch.c @@ -304,7 +304,14 @@ void *thread_calc_stdin (void *p) if (device_param->skipped) return NULL; - calc_stdin (hashcat_ctx, device_param); // we should check the RC here + const int rc_calc = calc_stdin (hashcat_ctx, device_param); + + if (rc_calc == -1) + { + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + + status_ctx->devices_status = STATUS_ERROR; + } return NULL; } @@ -716,7 +723,14 @@ void *thread_calc (void *p) if (device_param->skipped) return NULL; - calc (hashcat_ctx, device_param); // we should check the RC here + const int rc_calc = calc (hashcat_ctx, device_param); + + if (rc_calc == -1) + { + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + + status_ctx->devices_status = STATUS_ERROR; + } return NULL; } diff --git a/src/hashcat.c b/src/hashcat.c index 728600443..d649b57e1 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -265,6 +265,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) } if ((status_ctx->devices_status != STATUS_CRACKED) + && (status_ctx->devices_status != STATUS_ERROR) && (status_ctx->devices_status != STATUS_ABORTED) && (status_ctx->devices_status != STATUS_ABORTED_CHECKPOINT) && (status_ctx->devices_status != STATUS_ABORTED_RUNTIME) @@ -1239,6 +1240,7 @@ int hashcat_session_execute (hashcat_ctx_t *hashcat_ctx) if (status_ctx->devices_status == STATUS_QUIT) rc_final = 2; if (status_ctx->devices_status == STATUS_EXHAUSTED) rc_final = 1; if (status_ctx->devices_status == STATUS_CRACKED) rc_final = 0; + if (status_ctx->devices_status == STATUS_ERROR) rc_final = -1; } // done diff --git a/src/status.c b/src/status.c index b2099d1ea..c2ffe2716 100644 --- a/src/status.c +++ b/src/status.c @@ -33,6 +33,7 @@ static const char *ST_0009 = "Bypass"; static const char *ST_0010 = "Aborted (Checkpoint)"; static const char *ST_0011 = "Aborted (Runtime)"; static const char *ST_0012 = "Running (Checkpoint Quit requested)"; +static const char *ST_0013 = "Error"; static const char *ST_9999 = "Unknown! Bug!"; static const char UNITS[7] = { ' ', 'k', 'M', 'G', 'T', 'P', 'E' }; @@ -227,6 +228,7 @@ const char *status_get_status_string (const hashcat_ctx_t *hashcat_ctx) case STATUS_BYPASS: return ST_0009; case STATUS_ABORTED_CHECKPOINT: return ST_0010; case STATUS_ABORTED_RUNTIME: return ST_0011; + case STATUS_ERROR: return ST_0013; } return ST_9999;