From 3156b487b74e1309b8009c7a40b229c4046560c1 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Wed, 9 Feb 2022 22:25:07 +0000 Subject: [PATCH] Avoid quoting OpenCL include path when it's not required to --- src/backend.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/backend.c b/src/backend.c index f370dca28..4db54c13a 100644 --- a/src/backend.c +++ b/src/backend.c @@ -9392,22 +9392,23 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) char *build_options_buf = (char *) hcmalloc (build_options_sz); - int build_options_len = 0; + int build_options_len = snprintf (build_options_buf, build_options_sz, "-D KERNEL_STATIC "); if ((device_param->is_cuda == true) || (device_param->is_hip == 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 "); } else { // when is builded with cygwin and msys, cpath_real doesn't work + #if defined (_WIN) || defined (__CYGWIN__) || defined (__MSYS__) - build_options_len += snprintf (build_options_buf + build_options_len, build_options_sz - build_options_len, "-D KERNEL_STATIC -D INCLUDE_PATH=%s ", "OpenCL"); + build_options_len += snprintf (build_options_buf + build_options_len, build_options_sz - build_options_len, "-D INCLUDE_PATH=%s ", "OpenCL"); #else - build_options_len += snprintf (build_options_buf + build_options_len, build_options_sz - build_options_len, "-D KERNEL_STATIC -D INCLUDE_PATH=\"%s\" ", folder_config->cpath_real); + const char *build_options_include_fmt = (strchr (folder_config->cpath_real, ' ') != NULL) ? "-D INCLUDE_PATH=\"%s\" " : "-D INCLUDE_PATH=%s "; + + build_options_len += snprintf (build_options_buf + build_options_len, build_options_sz - build_options_len, build_options_include_fmt, folder_config->cpath_real); #endif build_options_len += snprintf (build_options_buf + build_options_len, build_options_sz - build_options_len, "-D XM2S(x)=#x ");