diff options
author | Eric Engestrom <[email protected]> | 2018-10-23 15:27:51 +0100 |
---|---|---|
committer | Eric Engestrom <[email protected]> | 2018-10-24 18:15:56 +0100 |
commit | ed5d65a6a1a01f2b6227d461bcfb02642a1bb608 (patch) | |
tree | 83cf449d9937a9a7f95cc23c989642e54b286ff0 /src | |
parent | 33d757096dafd5e66f92e2a36e6855de6e8724d2 (diff) |
anv: use snprintf() instead of memset()+strcpy()
snprintf() guarantees that it will not write more chars than allowed,
and that the string will be null-terminated, without the need to fill
the whole thing with zeroes to begin with.
Signed-off-by: Eric Engestrom <[email protected]>
Reviewed-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/intel/vulkan/anv_device.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index c009176dcc6..3ac1bad93ed 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -37,6 +37,7 @@ #include "util/build_id.h" #include "util/disk_cache.h" #include "util/mesa-sha1.h" +#include "util/u_string.h" #include "git_sha1.h" #include "vk_util.h" #include "common/gen_defines.h" @@ -1135,12 +1136,10 @@ void anv_GetPhysicalDeviceProperties2( (VkPhysicalDeviceDriverPropertiesKHR *) ext; driver_props->driverID = VK_DRIVER_ID_INTEL_OPEN_SOURCE_MESA_KHR; - memset(driver_props->driverName, 0, VK_MAX_DRIVER_NAME_SIZE_KHR); - strcpy(driver_props->driverName, + util_snprintf(driver_props->driverName, VK_MAX_DRIVER_NAME_SIZE_KHR, "Intel open-source Mesa driver"); - memset(driver_props->driverInfo, 0, VK_MAX_DRIVER_INFO_SIZE_KHR); - strcpy(driver_props->driverInfo, + util_snprintf(driver_props->driverInfo, VK_MAX_DRIVER_INFO_SIZE_KHR, "Mesa " PACKAGE_VERSION MESA_GIT_SHA1); driver_props->conformanceVersion = (VkConformanceVersionKHR) { |