diff --git a/docs/changes.txt b/docs/changes.txt index de66f788e..6d7c2b841 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -37,6 +37,7 @@ ## - Autodetect: Limit the number of errors per hash-mode try to 100 to avoid long startup time +- Folders: Do not escape the variable cpath_real to prevent certain OpenCL runtimes from running into an error which do not support escape characters - LM: Workaround JiT compiler bug in -m 3000 on NV leading to false negatives with large amount of hashes - Tests: Changed tests for VeraCrypt from -a 0 to -a 3, because password extension is not available to all shells diff --git a/src/backend.c b/src/backend.c index c5c3828a4..6892eb7c1 100644 --- a/src/backend.c +++ b/src/backend.c @@ -7714,7 +7714,8 @@ static u32 get_kernel_threads (const hc_device_param_t *device_param) static bool load_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const char *kernel_name, char *source_file, char *cached_file, const char *build_options_buf, const bool cache_disable, cl_program *opencl_program, CUmodule *cuda_module) { - const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + const folder_config_t *folder_config = hashcat_ctx->folder_config; bool cached = true; @@ -7761,7 +7762,7 @@ static bool load_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_p if (hc_nvrtcCreateProgram (hashcat_ctx, &program, kernel_sources[0], kernel_name, 0, NULL, NULL) == -1) return false; - char **nvrtc_options = (char **) hccalloc (4 + strlen (build_options_buf) + 1, sizeof (char *)); // ... + char **nvrtc_options = (char **) hccalloc (6 + strlen (build_options_buf) + 1, sizeof (char *)); // ... nvrtc_options[0] = "--restrict"; nvrtc_options[1] = "--device-as-default-execution-space"; @@ -7769,9 +7770,12 @@ static bool load_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_p hc_asprintf (&nvrtc_options[3], "compute_%d%d", device_param->sm_major, device_param->sm_minor); + nvrtc_options[4] = "-I"; + nvrtc_options[5] = folder_config->cpath_real; + char *nvrtc_options_string = hcstrdup (build_options_buf); - const int num_options = 4 + nvrtc_make_options_array_from_string (nvrtc_options_string, nvrtc_options + 4); + const int num_options = 6 + nvrtc_make_options_array_from_string (nvrtc_options_string, nvrtc_options + 6); const int rc_nvrtcCompileProgram = hc_nvrtcCompileProgram (hashcat_ctx, program, num_options, (const char * const *) nvrtc_options); @@ -8646,11 +8650,17 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) int build_options_len = 0; - #if defined (_WIN) - build_options_len += snprintf (build_options_buf + build_options_len, build_options_sz - build_options_len, "-D KERNEL_STATIC -I OpenCL -I \"%s\" ", folder_config->cpath_real); - #else - build_options_len += snprintf (build_options_buf + build_options_len, build_options_sz - build_options_len, "-D KERNEL_STATIC -I OpenCL -I %s ", folder_config->cpath_real); - #endif + if (device_param->is_cuda == true) + { + // using a path with a space will break nvrtc_make_options_array_from_string() + // we add it to options array in a clean way later + + build_options_len += snprintf (build_options_buf + build_options_len, build_options_sz - build_options_len, "-D KERNEL_STATIC -I OpenCL "); + } + else + { + build_options_len += snprintf (build_options_buf + build_options_len, build_options_sz - build_options_len, "-D KERNEL_STATIC -I OpenCL -I \"%s\" ", folder_config->cpath_real); + } /* currently disabled, hangs NEO drivers since 20.09. was required for NEO driver 20.08 to workaround the same issue! diff --git a/src/folder.c b/src/folder.c index 12f1f9727..eb5914dbe 100644 --- a/src/folder.c +++ b/src/folder.c @@ -507,16 +507,12 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins } */ - #if defined (_WIN) - - naive_replace (cpath_real, '\\', '/'); - - // not escaping here, windows using quotes later + // not escaping here, using quotes later // naive_escape (cpath_real, PATH_MAX, ' ', '\\'); - #else + #if defined (_WIN) - naive_escape (cpath_real, PATH_MAX, ' ', '\\'); + naive_replace (cpath_real, '\\', '/'); #endif