diff options
author | Aron Virginas-Tar <aron.virginas-tar@arm.com> | 2022-07-14 13:59:12 +0100 |
---|---|---|
committer | Matteo Franchin <matteo.franchin@arm.com> | 2022-08-03 13:39:26 +0000 |
commit | 36b640c468e1549632e7e7228471ecb7e65b2cea (patch) | |
tree | 9ca1a7e75ae63516f073f3c6c8d2b5cbad1ee9b3 | |
parent | 425b885f6e607eecd5ccb4b7f15bf77592dbe267 (diff) | |
download | vulkan-wsi-layer-36b640c468e1549632e7e7228471ecb7e65b2cea.tar.gz vulkan-wsi-layer-36b640c468e1549632e7e7228471ecb7e65b2cea.tar.bz2 vulkan-wsi-layer-36b640c468e1549632e7e7228471ecb7e65b2cea.zip |
Fix issue found by static analysis
Replaced call to unsafe function strcpy() with call to snprintf().
Signed-off-by: Aron Virginas-Tar <aron.virginas-tar@arm.com>
Change-Id: I0de5f869200e74b6d0c8224da2e41d6c4b8b6f4d
-rw-r--r-- | util/extension_list.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/util/extension_list.cpp b/util/extension_list.cpp index fd857c2..3d91b6e 100644 --- a/util/extension_list.cpp +++ b/util/extension_list.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021 Arm Limited. + * Copyright (c) 2019, 2021-2022 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -25,6 +25,7 @@ #include "extension_list.hpp" #include "util/custom_allocator.hpp" #include <layer/private_data.hpp> +#include <cstdio> #include <cstring> #include <cassert> @@ -47,11 +48,13 @@ VkResult extension_list::add(const char *const *extensions, uint32_t count) for (uint32_t i = 0; i < count; i++) { auto &dst = m_ext_props[initial_size + i]; - if (strlen(extensions[i]) >= sizeof(dst.extensionName)) + + const size_t len = strlen(extensions[i]); + if (len >= sizeof(dst.extensionName)) { abort(); } - strcpy(dst.extensionName, extensions[i]); + snprintf(dst.extensionName, len + 1, "%s", extensions[i]); } return VK_SUCCESS; } |