Workaround OpenCL runtimes that do not accept -I parameter in the OpenCL kernel build...
authorjsteube <jens.steube@gmail.com>
Mon, 11 Jul 2016 21:45:25 +0000 (23:45 +0200)
committerjsteube <jens.steube@gmail.com>
Mon, 11 Jul 2016 21:45:25 +0000 (23:45 +0200)
docs/changes.txt
src/hashcat.c

index 666b5eb..ffac0c9 100644 (file)
@@ -15,6 +15,7 @@
 - Allow the use of enc_id == 0 in hash-mode 10600 and 10700 as it takes no part in the actual computation
 - Get rid of exit() calls in OpenCL wrapper library with the goal to have a better control which error can be ignored under special circumstances
 - Do not error and exit if an OpenCL platform has no devices, just print a warning and continue with the next platform
+- Workaround OpenCL runtimes that do not accept -I parameter in the OpenCL kernel build options even if this is an OpenCL standard option
 
 ##
 ## Bugs
index 027dd02..c45ede9 100644 (file)
@@ -6147,6 +6147,22 @@ int main (int argc, char **argv)
 
   umask (077);
 
+  /**
+   * There's some buggy OpenCL runtime that do not support -I.
+   * A workaround is to chdir() to the OpenCL folder,
+   * then compile the kernels,
+   * then chdir() back to where we came from so we need to save it first
+   */
+
+  char cwd[1024];
+
+  if (getcwd (cwd, sizeof (cwd) - 1) == NULL)
+  {
+    log_error ("ERROR: getcwd(): %s", strerror (errno));
+
+    return -1;
+  }
+
   /**
    * Real init
    */
@@ -16140,17 +16156,20 @@ int main (int argc, char **argv)
         "inc_vendor.cl",
       };
 
-      for (int i = 0; i < files_cnt; i++)
+      if (chdir (cpath_real) == -1)
       {
-        char path[1024] = { 0 };
+        log_error ("ERROR: %s: %s", cpath_real, strerror (errno));
 
-        snprintf (path, sizeof (path) - 1, "%s/%s", cpath_real, files_names[i]);
+        return -1;
+      }
 
-        FILE *fd = fopen (path, "r");
+      for (int i = 0; i < files_cnt; i++)
+      {
+        FILE *fd = fopen (files_names[i], "r");
 
         if (fd == NULL)
         {
-          log_error ("ERROR: %s: fopen(): %s", path, strerror (errno));
+          log_error ("ERROR: %s: fopen(): %s", files_names[i], strerror (errno));
 
           return -1;
         }
@@ -16161,7 +16180,7 @@ int main (int argc, char **argv)
 
         if (n != 1)
         {
-          log_error ("ERROR: %s: fread(): %s", path, strerror (errno));
+          log_error ("ERROR: %s: fread(): %s", files_names[i], strerror (errno));
 
           return -1;
         }
@@ -16718,6 +16737,15 @@ int main (int argc, char **argv)
         local_free (kernel_sources);
       }
 
+      // return back to the folder we came from initially (workaround)
+
+      if (chdir (cwd) == -1)
+      {
+        log_error ("ERROR: %s: %s", cwd, strerror (errno));
+
+        return -1;
+      }
+
       // some algorithm collide too fast, make that impossible
 
       if (benchmark == 1)