Skip to content

Commit f25f0d6

Browse files
committed
Change xrt_xclbin.cpp
1 parent 610fa6e commit f25f0d6

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/runtime_src/core/common/api/xrt_xclbin.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,10 +1748,15 @@ xrtXclbinGetXSAName(xrtXclbinHandle handle, char* name, int size, int* ret_size)
17481748
const std::string& xsaname = xclbin->get_xsa_name();
17491749
// populate ret_size if memory is allocated
17501750
if (ret_size)
1751-
*ret_size = xsaname.size();
1751+
*ret_size = xsaname.size() + 1;
17521752
// populate name if memory is allocated
1753-
if (name)
1754-
std::strncpy(name, xsaname.c_str(), size);
1753+
if (!name || size == 0)
1754+
return 0;
1755+
1756+
auto cp_len = std::min(size - 1, static_cast<int>(xsaname.size()));
1757+
std::memcpy(name, xsaname.c_str(), cp_len);
1758+
name[cp_len] = 0;
1759+
17551760
return 0;
17561761
});
17571762
}

0 commit comments

Comments
 (0)