From 7b7caf38423e915e70fbf90c4e49283be57d5d99 Mon Sep 17 00:00:00 2001 From: philsmd Date: Thu, 7 Jan 2016 16:35:45 +0100 Subject: [PATCH] added additional --opencl-platform check (reject numbers > number of OpenCL platforms) --- src/oclHashcat.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/oclHashcat.c b/src/oclHashcat.c index 63a8d6f1e..0f55a56fd 100644 --- a/src/oclHashcat.c +++ b/src/oclHashcat.c @@ -12300,7 +12300,12 @@ int main (int argc, char **argv) return (-1); } - uint CL_platform_sel = 0; + uint CL_platform_sel = 1; + + if (opencl_platform != NULL) + { + CL_platform_sel = atoi (opencl_platform); + } if (CL_platforms_cnt > 1) { @@ -12330,20 +12335,28 @@ int main (int argc, char **argv) } else { - CL_platform_sel = atoi (opencl_platform); - if (CL_platform_sel > CL_platforms_cnt) { log_error ("ERROR: invalid OpenCL platforms selected"); return (-1); } - - // user does not count with zero - - CL_platform_sel -= 1; } } + else + { + if (CL_platform_sel != 1) + { + log_error ("ERROR: OpenCL platform number %d not available", CL_platform_sel); + + return (-1); + } + } + + // zero-indexed: not starting to count at 1, as user does + + CL_platform_sel -= 1; + cl_platform_id CL_platform = CL_platforms[CL_platform_sel];