1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-12-23 15:18:16 +00:00

Merge pull request #2865 from jtojanen/fixes

Fix several backend leaks
This commit is contained in:
Jens Steube 2021-07-06 09:34:47 +02:00 committed by GitHub
commit 13e2aa2508
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5415,7 +5415,12 @@ int backend_ctx_init (hashcat_ctx_t *hashcat_ctx)
char *opencl_platform_vendor = (char *) hcmalloc (param_value_size); char *opencl_platform_vendor = (char *) hcmalloc (param_value_size);
if (hc_clGetPlatformInfo (hashcat_ctx, opencl_platform, CL_PLATFORM_VENDOR, param_value_size, opencl_platform_vendor, NULL) == -1) return -1; if (hc_clGetPlatformInfo (hashcat_ctx, opencl_platform, CL_PLATFORM_VENDOR, param_value_size, opencl_platform_vendor, NULL) == -1)
{
hcfree (opencl_platform_vendor);
return -1;
}
opencl_platforms_vendor[opencl_platforms_idx] = opencl_platform_vendor; opencl_platforms_vendor[opencl_platforms_idx] = opencl_platform_vendor;
@ -5425,7 +5430,12 @@ int backend_ctx_init (hashcat_ctx_t *hashcat_ctx)
char *opencl_platform_name = (char *) hcmalloc (param_value_size); char *opencl_platform_name = (char *) hcmalloc (param_value_size);
if (hc_clGetPlatformInfo (hashcat_ctx, opencl_platform, CL_PLATFORM_NAME, param_value_size, opencl_platform_name, NULL) == -1) return -1; if (hc_clGetPlatformInfo (hashcat_ctx, opencl_platform, CL_PLATFORM_NAME, param_value_size, opencl_platform_name, NULL) == -1)
{
hcfree (opencl_platform_name);
return -1;
}
opencl_platforms_name[opencl_platforms_idx] = opencl_platform_name; opencl_platforms_name[opencl_platforms_idx] = opencl_platform_name;
@ -5435,7 +5445,12 @@ int backend_ctx_init (hashcat_ctx_t *hashcat_ctx)
char *opencl_platform_version = (char *) hcmalloc (param_value_size); char *opencl_platform_version = (char *) hcmalloc (param_value_size);
if (hc_clGetPlatformInfo (hashcat_ctx, opencl_platform, CL_PLATFORM_VERSION, param_value_size, opencl_platform_version, NULL) == -1) return -1; if (hc_clGetPlatformInfo (hashcat_ctx, opencl_platform, CL_PLATFORM_VERSION, param_value_size, opencl_platform_version, NULL) == -1)
{
hcfree (opencl_platform_version);
return -1;
}
opencl_platforms_version[opencl_platforms_idx] = opencl_platform_version; opencl_platforms_version[opencl_platforms_idx] = opencl_platform_version;
@ -5724,6 +5739,7 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime)
if (hc_cuDeviceGetName (hashcat_ctx, device_name, HCBUFSIZ_TINY, cuda_device) == -1) if (hc_cuDeviceGetName (hashcat_ctx, device_name, HCBUFSIZ_TINY, cuda_device) == -1)
{ {
device_param->skipped = true; device_param->skipped = true;
hcfree (device_name);
continue; continue;
} }
@ -6126,7 +6142,7 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime)
#define CHECK_BOARD_NAME_AMD 1 #define CHECK_BOARD_NAME_AMD 1
cl_int rc_board_name_amd = 0; cl_int rc_board_name_amd = CL_INVALID_VALUE;
if (CHECK_BOARD_NAME_AMD) if (CHECK_BOARD_NAME_AMD)
{ {
@ -6150,6 +6166,7 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime)
if (hc_clGetDeviceInfo (hashcat_ctx, device_param->opencl_device, CL_DEVICE_BOARD_NAME_AMD, param_value_size, device_name, NULL) == -1) if (hc_clGetDeviceInfo (hashcat_ctx, device_param->opencl_device, CL_DEVICE_BOARD_NAME_AMD, param_value_size, device_name, NULL) == -1)
{ {
device_param->skipped = true; device_param->skipped = true;
hcfree (device_name);
continue; continue;
} }
@ -6168,6 +6185,7 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime)
if (hc_clGetDeviceInfo (hashcat_ctx, device_param->opencl_device, CL_DEVICE_NAME, param_value_size, device_name, NULL) == -1) if (hc_clGetDeviceInfo (hashcat_ctx, device_param->opencl_device, CL_DEVICE_NAME, param_value_size, device_name, NULL) == -1)
{ {
device_param->skipped = true; device_param->skipped = true;
hcfree (device_name);
continue; continue;
} }
@ -6191,6 +6209,7 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime)
if (hc_clGetDeviceInfo (hashcat_ctx, device_param->opencl_device, CL_DEVICE_VENDOR, param_value_size, opencl_device_vendor, NULL) == -1) if (hc_clGetDeviceInfo (hashcat_ctx, device_param->opencl_device, CL_DEVICE_VENDOR, param_value_size, opencl_device_vendor, NULL) == -1)
{ {
device_param->skipped = true; device_param->skipped = true;
hcfree (opencl_device_vendor);
continue; continue;
} }
@ -6266,6 +6285,7 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime)
if (hc_clGetDeviceInfo (hashcat_ctx, device_param->opencl_device, CL_DEVICE_VERSION, param_value_size, opencl_device_version, NULL) == -1) if (hc_clGetDeviceInfo (hashcat_ctx, device_param->opencl_device, CL_DEVICE_VERSION, param_value_size, opencl_device_version, NULL) == -1)
{ {
device_param->skipped = true; device_param->skipped = true;
hcfree (opencl_device_version);
continue; continue;
} }
@ -6284,6 +6304,7 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime)
if (hc_clGetDeviceInfo (hashcat_ctx, device_param->opencl_device, CL_DEVICE_OPENCL_C_VERSION, param_value_size, opencl_device_c_version, NULL) == -1) if (hc_clGetDeviceInfo (hashcat_ctx, device_param->opencl_device, CL_DEVICE_OPENCL_C_VERSION, param_value_size, opencl_device_c_version, NULL) == -1)
{ {
device_param->skipped = true; device_param->skipped = true;
hcfree (opencl_device_c_version);
continue; continue;
} }
@ -6438,6 +6459,7 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime)
if (hc_clGetDeviceInfo (hashcat_ctx, device_param->opencl_device, CL_DEVICE_EXTENSIONS, device_extensions_size, device_extensions, NULL) == -1) if (hc_clGetDeviceInfo (hashcat_ctx, device_param->opencl_device, CL_DEVICE_EXTENSIONS, device_extensions_size, device_extensions, NULL) == -1)
{ {
device_param->skipped = true; device_param->skipped = true;
hcfree (device_extensions);
continue; continue;
} }
@ -6686,6 +6708,7 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime)
if (hc_clGetDeviceInfo (hashcat_ctx, device_param->opencl_device, CL_DRIVER_VERSION, param_value_size, opencl_driver_version, NULL) == -1) if (hc_clGetDeviceInfo (hashcat_ctx, device_param->opencl_device, CL_DRIVER_VERSION, param_value_size, opencl_driver_version, NULL) == -1)
{ {
device_param->skipped = true; device_param->skipped = true;
hcfree (opencl_driver_version);
continue; continue;
} }
@ -7399,8 +7422,6 @@ void backend_ctx_devices_destroy (hashcat_ctx_t *hashcat_ctx)
{ {
hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx]; hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx];
if (device_param->skipped == true) continue;
hcfree (device_param->device_name); hcfree (device_param->device_name);
if (device_param->is_opencl == true) if (device_param->is_opencl == true)
@ -7806,6 +7827,9 @@ static bool load_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_p
const int rc_nvrtcCompileProgram = hc_nvrtcCompileProgram (hashcat_ctx, program, num_options, (const char * const *) nvrtc_options); const int rc_nvrtcCompileProgram = hc_nvrtcCompileProgram (hashcat_ctx, program, num_options, (const char * const *) nvrtc_options);
hcfree (nvrtc_options_string);
hcfree (nvrtc_options);
size_t build_log_size = 0; size_t build_log_size = 0;
hc_nvrtcGetProgramLogSize (hashcat_ctx, program, &build_log_size); hc_nvrtcGetProgramLogSize (hashcat_ctx, program, &build_log_size);
@ -7818,7 +7842,14 @@ static bool load_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_p
{ {
char *build_log = (char *) hcmalloc (build_log_size + 1); char *build_log = (char *) hcmalloc (build_log_size + 1);
if (hc_nvrtcGetProgramLog (hashcat_ctx, program, build_log) == -1) return false; if (hc_nvrtcGetProgramLog (hashcat_ctx, program, build_log) == -1)
{
hcfree (build_log);
return false;
}
build_log[build_log_size] = 0;
puts (build_log); puts (build_log);
@ -7832,9 +7863,6 @@ static bool load_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_p
return false; return false;
} }
hcfree (nvrtc_options);
hcfree (nvrtc_options_string);
size_t binary_size = 0; size_t binary_size = 0;
if (hc_nvrtcGetPTXSize (hashcat_ctx, program, &binary_size) == -1) return false; if (hc_nvrtcGetPTXSize (hashcat_ctx, program, &binary_size) == -1) return false;
@ -8035,7 +8063,14 @@ static bool load_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_p
const int rc_clGetProgramBuildInfo = hc_clGetProgramBuildInfo (hashcat_ctx, p1, device_param->opencl_device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); const int rc_clGetProgramBuildInfo = hc_clGetProgramBuildInfo (hashcat_ctx, p1, device_param->opencl_device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL);
if (rc_clGetProgramBuildInfo == -1) return false; if (rc_clGetProgramBuildInfo == -1)
{
hcfree (build_log);
return false;
}
build_log[build_log_size] = 0;
puts (build_log); puts (build_log);
@ -8738,7 +8773,7 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
* device_name_chksum_amp_mp * device_name_chksum_amp_mp
*/ */
char *device_name_chksum_amp_mp = (char *) hcmalloc (HCBUFSIZ_TINY); char device_name_chksum_amp_mp[HCBUFSIZ_TINY] = { 0 };
const size_t dnclen_amp_mp = snprintf (device_name_chksum_amp_mp, HCBUFSIZ_TINY, "%d-%d-%d-%u-%s-%s-%s", const size_t dnclen_amp_mp = snprintf (device_name_chksum_amp_mp, HCBUFSIZ_TINY, "%d-%d-%d-%u-%s-%s-%s",
backend_ctx->comptime, backend_ctx->comptime,
@ -8973,7 +9008,7 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
* device_name_chksum * device_name_chksum
*/ */
char *device_name_chksum = (char *) hcmalloc (HCBUFSIZ_TINY); char device_name_chksum[HCBUFSIZ_TINY] = { 0 };
// The kernel source can depend on some JiT compiler macros which themself depend on the attack_modes. // The kernel source can depend on some JiT compiler macros which themself depend on the attack_modes.
// ATM this is relevant only for ATTACK_MODE_ASSOCIATION which slightly modifies ATTACK_MODE_STRAIGHT kernels. // ATM this is relevant only for ATTACK_MODE_ASSOCIATION which slightly modifies ATTACK_MODE_STRAIGHT kernels.
@ -9038,8 +9073,6 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
} }
hcfree (build_options_module_buf); hcfree (build_options_module_buf);
hcfree (device_name_chksum);
} }
/** /**
@ -9151,8 +9184,6 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
if (hc_clUnloadPlatformCompiler (hashcat_ctx, platform_id) == -1) return -1; if (hc_clUnloadPlatformCompiler (hashcat_ctx, platform_id) == -1) return -1;
} }
hcfree (device_name_chksum_amp_mp);
// some algorithm collide too fast, make that impossible // some algorithm collide too fast, make that impossible
if (user_options->benchmark == true) if (user_options->benchmark == true)