From: Alastair Murray Date: Thu, 11 Apr 2019 16:17:06 +0000 (+0100) Subject: Do parameter validation in clGetExtensionFunctionAddress X-Git-Tag: upstream/v2022.01.04~55 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=66ecca5dce2c4425a48bdb0cf0de606e4da43ab5;p=platform%2Fupstream%2FOpenCL-ICD-Loader.git Do parameter validation in clGetExtensionFunctionAddress Also undefine the local macros as soon as possible. Patch originally from Jeroen Ketema. --- diff --git a/icd_dispatch.c b/icd_dispatch.c index ecf52fc..df967cb 100644 --- a/icd_dispatch.c +++ b/icd_dispatch.c @@ -1359,6 +1359,8 @@ CL_API_ENTRY void * CL_API_CALL clGetExtensionFunctionAddressForPlatform(cl_platform_id platform, const char * function_name) CL_API_SUFFIX__VERSION_1_2 { + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(function_name, NULL); + // make sure the ICD is initialized khrIcdInitialize(); @@ -1426,6 +1428,8 @@ clGetExtensionFunctionAddressForPlatform(cl_platform_id platform, /* cl_khr_sub_groups */ CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetKernelSubGroupInfoKHR); + #undef CL_COMMON_EXTENSION_ENTRYPOINT_ADD + // This is not an ICD-aware extension, so call into the implementation // to get the extension function address. @@ -1567,11 +1571,14 @@ clEnqueueBarrier(cl_command_queue command_queue) CL_EXT_SUFFIX__VERSION_1_1_DEPR CL_API_ENTRY void * CL_API_CALL clGetExtensionFunctionAddress(const char *function_name) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED { - size_t function_name_length = strlen(function_name); + size_t function_name_length = 0; KHRicdVendor* vendor = NULL; + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(function_name, NULL); + // make sure the ICD is initialized khrIcdInitialize(); + function_name_length = strlen(function_name); // return any ICD-aware extensions @@ -1637,6 +1644,8 @@ clGetExtensionFunctionAddress(const char *function_name) CL_EXT_SUFFIX__VERSION_ /* cl_khr_sub_groups */ CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetKernelSubGroupInfoKHR); + #undef CL_COMMON_EXTENSION_ENTRYPOINT_ADD + // fall back to vendor extension detection for (vendor = khrIcdVendors; vendor; vendor = vendor->next) {