this fixes the beta issue #163 (-d and --opencl-platforms not within valid range)
authorphilsmd <philsmd@hashcat.net>
Wed, 24 Feb 2016 18:50:05 +0000 (19:50 +0100)
committerphilsmd <philsmd@hashcat.net>
Wed, 24 Feb 2016 18:50:05 +0000 (19:50 +0100)
src/oclHashcat.c

index bcd8960..8101d1e 100644 (file)
@@ -12490,6 +12490,18 @@ int main (int argc, char **argv)
 
         return (-1);
       }
+
+      if (opencl_platforms_filter != (uint) -1)
+      {
+        uint platform_cnt_mask = ~((-1 >> platforms_cnt) << platforms_cnt);
+
+        if (opencl_platforms_filter > platform_cnt_mask)
+        {
+          log_error ("ERROR: The platform selected by the --opencl-platforms parameter is larger than the number of available platforms (%d)", platforms_cnt);
+
+          return (-1);
+        }
+      }
     }
 
     /**
@@ -12945,6 +12957,20 @@ int main (int argc, char **argv)
       return (-1);
     }
 
+    // additional check to see if the user has chosen a device that is not within the range of available devices (i.e. larger than devices_cnt)
+
+    if (devices_filter != (uint) -1)
+    {
+      uint devices_cnt_mask = ~((-1 >> devices_cnt) << devices_cnt);
+
+      if (devices_filter > devices_cnt_mask)
+      {
+        log_error ("ERROR: The device specified by the --opencl-devices parameter is larger than the number of available devices (%d)", devices_cnt);
+
+        return (-1);
+      }
+    }
+
     data.devices_cnt = devices_cnt;
 
     data.devices_active = devices_active;