From 02b4ec115b52aab65c43b489abe41c19116dd380 Mon Sep 17 00:00:00 2001 From: foreman Date: Sun, 21 Apr 2019 21:50:04 -0400 Subject: [PATCH] P4 to Git Change 1772349 by mshivama@mshivama_tf on 2019/04/20 07:35:24 SWDEV-187020 - Basic "Hello World" Tensorflow program fails to execute on HIP/VDI/PAL/LINUX Make sure that the size of `dest` is big enough to hoid `src` including trailing zero byte Affected files ... ... //depot/stg/opencl/drivers/opencl/api/hip/hip_device.cpp#19 edit --- hipamd/api/hip/hip_device.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hipamd/api/hip/hip_device.cpp b/hipamd/api/hip/hip_device.cpp index ae4ee89ccf..a3019cc7d7 100644 --- a/hipamd/api/hip/hip_device.cpp +++ b/hipamd/api/hip/hip_device.cpp @@ -118,11 +118,13 @@ hipError_t hipDeviceGetName(char *name, int len, hipDevice_t device) { const auto& info = deviceHandle->info(); const auto nameLen = ::strlen(info.boardName_); - if (nameLen > (cl_uint)len) { + // Make sure that the size of `dest` is big enough to hold `src` including + // trailing zero byte + if (nameLen > (cl_uint)(len - 1)) { HIP_RETURN(hipErrorInvalidValue); } - ::strncpy(name, info.boardName_, nameLen); + ::strncpy(name, info.boardName_, (nameLen + 1)); HIP_RETURN(hipSuccess); }