icd: Fixed to prevent string overflow. 71/193871/1
authorJoonbum Ko <joonbum.ko@samsung.com>
Tue, 27 Nov 2018 06:38:11 +0000 (15:38 +0900)
committerJoonbum Ko <joonbum.ko@samsung.com>
Tue, 27 Nov 2018 06:38:11 +0000 (15:38 +0900)
Change-Id: Ia486efdc975eb238044de0763fddfd3e3127bfdd
Signed-off-by: Joonbum Ko <joonbum.ko@samsung.com>
src/wsi/icd.c

index 6c52139..134eb72 100644 (file)
@@ -55,19 +55,22 @@ static const VkExtensionProperties wsi_instance_extensions[] = {
 static void __attribute__((constructor))
 module_init(void)
 {
-       const char      *filename;
+       const char      *env_filename;
+       char            icd_filepath[1024];
        uint32_t        count;
        VkResult        res;
        PFN_vkEnumerateInstanceExtensionProperties enum_inst_exts;
 
        /* Get env var for ICD path. */
-       filename = getenv("VK_TIZEN_ICD");
-       VK_CHECK(filename, return, "No ICD library given.\n");
+       env_filename = getenv("VK_TIZEN_ICD");
+       VK_CHECK(env_filename, return, "No ICD library given.\n");
 
        dlerror();
 
+       strncpy(icd_filepath, env_filename, sizeof(icd_filepath));
+
        /* Open ICD file. */
-       icd.lib = dlopen(filename, RTLD_LAZY | RTLD_LOCAL);
+       icd.lib = dlopen(icd_filepath, RTLD_LAZY | RTLD_LOCAL);
        VK_CHECK(icd.lib, return, "dlopen() failed - %s\n", dlerror());
 
        /* Retrieve our first entry point for vulkan symbols. */