From bfbc4279f4f00acc32ff1774acee967c1a654ffc Mon Sep 17 00:00:00 2001 From: jsteube Date: Sat, 15 Oct 2016 19:44:31 +0200 Subject: [PATCH] Add some more returncode checks --- src/autotune.c | 36 ++++++++++++++++++------------------ src/dispatch.c | 46 ++++++++++++++++++++++++++++++++++++---------- 2 files changed, 54 insertions(+), 28 deletions(-) diff --git a/src/autotune.c b/src/autotune.c index 9ca5e8955..5602faee0 100644 --- a/src/autotune.c +++ b/src/autotune.c @@ -82,9 +82,13 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param const u32 kernel_power_max = device_param->device_processors * device_param->kernel_threads * kernel_accel_max; + int CL_rc; + if (user_options_extra->attack_kern == ATTACK_KERN_BF) { - run_kernel_memset (hashcat_ctx, device_param, device_param->d_pws_buf, 7, kernel_power_max * sizeof (pw_t)); + CL_rc = run_kernel_memset (hashcat_ctx, device_param, device_param->d_pws_buf, 7, kernel_power_max * sizeof (pw_t)); + + if (CL_rc == -1) return -1; } else { @@ -95,33 +99,25 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param device_param->pws_buf[i].pw_len = 7 + (i & 7); } - cl_int CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, kernel_power_max * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL); + CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, kernel_power_max * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "clEnqueueWriteBuffer(): %s", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_rc == -1) return -1; } if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) { if (straight_ctx->kernel_rules_cnt > 1) { - cl_int CL_err = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_rules, device_param->d_rules_c, 0, 0, MIN (kernel_loops_max, KERNEL_RULES) * sizeof (kernel_rule_t), 0, NULL, NULL); + CL_rc = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_rules, device_param->d_rules_c, 0, 0, MIN (kernel_loops_max, KERNEL_RULES) * sizeof (kernel_rule_t), 0, NULL, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "clEnqueueCopyBuffer(): %s", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_rc == -1) return -1; } } else { - run_kernel_amp (hashcat_ctx, device_param, kernel_power_max); + CL_rc = run_kernel_amp (hashcat_ctx, device_param, kernel_power_max); + + if (CL_rc == -1) return -1; } #define VERIFIER_CNT 1 @@ -252,11 +248,15 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_amp_buf, CL_TRUE, 0, kernel_power_max * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL); */ - run_kernel_memset (hashcat_ctx, device_param, device_param->d_pws_buf, 0, kernel_power_max * sizeof (pw_t)); + CL_rc = run_kernel_memset (hashcat_ctx, device_param, device_param->d_pws_buf, 0, kernel_power_max * sizeof (pw_t)); + + if (CL_rc == -1) return -1; if (hashconfig->attack_exec == ATTACK_EXEC_OUTSIDE_KERNEL) { - run_kernel_memset (hashcat_ctx, device_param, device_param->d_pws_amp_buf, 0, kernel_power_max * sizeof (pw_t)); + CL_rc = run_kernel_memset (hashcat_ctx, device_param, device_param->d_pws_amp_buf, 0, kernel_power_max * sizeof (pw_t)); + + if (CL_rc == -1) return -1; } // reset timer diff --git a/src/dispatch.c b/src/dispatch.c index e50a4a675..d8894f444 100644 --- a/src/dispatch.c +++ b/src/dispatch.c @@ -200,9 +200,15 @@ static int calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par if (pws_cnt) { - run_copy (hashcat_ctx, device_param, pws_cnt); + int CL_rc; - run_cracker (hashcat_ctx, device_param, pws_cnt); + CL_rc = run_copy (hashcat_ctx, device_param, pws_cnt); + + if (CL_rc == -1) return -1; + + CL_rc = run_cracker (hashcat_ctx, device_param, pws_cnt); + + if (CL_rc == -1) return -1; device_param->pws_cnt = 0; @@ -210,11 +216,15 @@ static int calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par still required? if (attack_kern == ATTACK_KERN_STRAIGHT) { - run_kernel_bzero (opencl_ctx, device_param, device_param->d_rules_c, device_param->size_rules_c); + CL_rc = run_kernel_bzero (opencl_ctx, device_param, device_param->d_rules_c, device_param->size_rules_c); + + if (CL_rc == -1) return -1; } else if (attack_kern == ATTACK_KERN_COMBI) { - run_kernel_bzero (opencl_ctx, device_param, device_param->d_combs_c, device_param->size_combs); + rCL_rc = un_kernel_bzero (opencl_ctx, device_param, device_param->d_combs_c, device_param->size_combs); + + if (CL_rc == -1) return -1; } */ } @@ -281,9 +291,15 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) if (pws_cnt) { - run_copy (hashcat_ctx, device_param, pws_cnt); + int CL_rc; - run_cracker (hashcat_ctx, device_param, pws_cnt); + CL_rc = run_copy (hashcat_ctx, device_param, pws_cnt); + + if (CL_rc == -1) return -1; + + CL_rc = run_cracker (hashcat_ctx, device_param, pws_cnt); + + if (CL_rc == -1) return -1; device_param->pws_cnt = 0; } @@ -504,9 +520,15 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) if (pws_cnt) { - run_copy (hashcat_ctx, device_param, pws_cnt); + int CL_rc; - run_cracker (hashcat_ctx, device_param, pws_cnt); + CL_rc = run_copy (hashcat_ctx, device_param, pws_cnt); + + if (CL_rc == -1) return -1; + + CL_rc = run_cracker (hashcat_ctx, device_param, pws_cnt); + + if (CL_rc == -1) return -1; device_param->pws_cnt = 0; @@ -514,11 +536,15 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) still required? if (attack_kern == ATTACK_KERN_STRAIGHT) { - run_kernel_bzero (device_param, device_param->d_rules_c, device_param->size_rules_c); + CL_rc = run_kernel_bzero (device_param, device_param->d_rules_c, device_param->size_rules_c); + + if (CL_rc == -1) return -1; } else if (attack_kern == ATTACK_KERN_COMBI) { - run_kernel_bzero (device_param, device_param->d_combs_c, device_param->size_combs); + CL_rc = run_kernel_bzero (device_param, device_param->d_combs_c, device_param->size_combs); + + if (CL_rc == -1) return -1; } */ }