mirror of
https://github.com/hashcat/hashcat.git
synced 2024-12-23 23:19:09 +00:00
Dispatcher: Fixed several memory leaks when an OpenCL error occurs
This commit is contained in:
parent
7f28c22b25
commit
291c1bcdd2
@ -59,6 +59,7 @@
|
||||
- Building: Replaced linking of CRT_glob.o with the use of int _dowildcard
|
||||
- Commandline: Do some checks related to custom-charset options if user specifies them
|
||||
- CPU Affinity: Fixed memory leak when invalid cpu Id was specified
|
||||
- Dispatcher: Fixed several memory leaks when an OpenCL error occurs
|
||||
- Events: Improved the maximum event message handling. event_log () will now also internally make sure that the message is properly terminated
|
||||
- Files: Do several file and folder checks on startup rather than when they are actually used to avoid related error after eventual intense operations
|
||||
- Helper: Added functions to check existence, type, read- and write-permissions and rewrite sources to use them instead of stat()
|
||||
|
106
src/dispatch.c
106
src/dispatch.c
@ -213,11 +213,21 @@ static int calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par
|
||||
|
||||
CL_rc = run_copy (hashcat_ctx, device_param, device_param->pws_cnt);
|
||||
|
||||
if (CL_rc == -1) return -1;
|
||||
if (CL_rc == -1)
|
||||
{
|
||||
hcfree (buf);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
CL_rc = run_cracker (hashcat_ctx, device_param, device_param->pws_cnt);
|
||||
|
||||
if (CL_rc == -1) return -1;
|
||||
if (CL_rc == -1)
|
||||
{
|
||||
hcfree (buf);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
device_param->pws_cnt = 0;
|
||||
|
||||
@ -317,19 +327,7 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
|
||||
{
|
||||
dictfile = combinator_ctx->dict2;
|
||||
}
|
||||
}
|
||||
|
||||
FILE *fd = fopen (dictfile, "rb");
|
||||
|
||||
if (fd == NULL)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s: %s", dictfile, strerror (errno));
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (attack_mode == ATTACK_MODE_COMBI)
|
||||
{
|
||||
const u32 combs_mode = combinator_ctx->combs_mode;
|
||||
|
||||
if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
|
||||
@ -342,8 +340,6 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s: %s", combinator_ctx->dict2, strerror (errno));
|
||||
|
||||
fclose (fd);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -359,8 +355,6 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s: %s", dictfilec, strerror (errno));
|
||||
|
||||
fclose (fd);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -368,6 +362,15 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
|
||||
}
|
||||
}
|
||||
|
||||
FILE *fd = fopen (dictfile, "rb");
|
||||
|
||||
if (fd == NULL)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s: %s", dictfile, strerror (errno));
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
hashcat_ctx_t *hashcat_ctx_tmp = (hashcat_ctx_t *) hcmalloc (sizeof (hashcat_ctx_t));
|
||||
|
||||
/*
|
||||
@ -404,8 +407,14 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
|
||||
|
||||
if (rc_wl_data_init == -1)
|
||||
{
|
||||
if (attack_mode == ATTACK_MODE_COMBI) fclose (device_param->combs_fp);
|
||||
|
||||
fclose (fd);
|
||||
|
||||
hcfree (hashcat_ctx_tmp->wl_data);
|
||||
|
||||
hcfree (hashcat_ctx_tmp);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -519,11 +528,33 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
|
||||
|
||||
CL_rc = run_copy (hashcat_ctx, device_param, pws_cnt);
|
||||
|
||||
if (CL_rc == -1) return -1;
|
||||
if (CL_rc == -1)
|
||||
{
|
||||
if (attack_mode == ATTACK_MODE_COMBI) fclose (device_param->combs_fp);
|
||||
|
||||
fclose (fd);
|
||||
|
||||
hcfree (hashcat_ctx_tmp->wl_data);
|
||||
|
||||
hcfree (hashcat_ctx_tmp);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
CL_rc = run_cracker (hashcat_ctx, device_param, pws_cnt);
|
||||
|
||||
if (CL_rc == -1) return -1;
|
||||
if (CL_rc == -1)
|
||||
{
|
||||
if (attack_mode == ATTACK_MODE_COMBI) fclose (device_param->combs_fp);
|
||||
|
||||
fclose (fd);
|
||||
|
||||
hcfree (hashcat_ctx_tmp->wl_data);
|
||||
|
||||
hcfree (hashcat_ctx_tmp);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
device_param->pws_cnt = 0;
|
||||
|
||||
@ -533,13 +564,35 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
|
||||
{
|
||||
CL_rc = run_kernel_bzero (device_param, device_param->d_rules_c, device_param->size_rules_c);
|
||||
|
||||
if (CL_rc == -1) return -1;
|
||||
if (CL_rc == -1)
|
||||
{
|
||||
if (attack_mode == ATTACK_MODE_COMBI) fclose (device_param->combs_fp);
|
||||
|
||||
fclose (fd);
|
||||
|
||||
hcfree (hashcat_ctx_tmp->wl_data);
|
||||
|
||||
hcfree (hashcat_ctx_tmp);
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if (attack_kern == ATTACK_KERN_COMBI)
|
||||
{
|
||||
CL_rc = run_kernel_bzero (device_param, device_param->d_combs_c, device_param->size_combs);
|
||||
|
||||
if (CL_rc == -1) return -1;
|
||||
if (CL_rc == -1)
|
||||
{
|
||||
if (attack_mode == ATTACK_MODE_COMBI) fclose (device_param->combs_fp);
|
||||
|
||||
fclose (fd);
|
||||
|
||||
hcfree (hashcat_ctx_tmp->wl_data);
|
||||
|
||||
hcfree (hashcat_ctx_tmp);
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
@ -558,18 +611,15 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
|
||||
if (words_fin == 0) break;
|
||||
}
|
||||
|
||||
if (attack_mode == ATTACK_MODE_COMBI)
|
||||
{
|
||||
fclose (device_param->combs_fp);
|
||||
}
|
||||
if (attack_mode == ATTACK_MODE_COMBI) fclose (device_param->combs_fp);
|
||||
|
||||
fclose (fd);
|
||||
|
||||
wl_data_destroy (hashcat_ctx_tmp);
|
||||
|
||||
hcfree (hashcat_ctx_tmp->wl_data);
|
||||
|
||||
hcfree (hashcat_ctx_tmp);
|
||||
|
||||
fclose (fd);
|
||||
}
|
||||
|
||||
device_param->kernel_accel = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user