Use correct destination size when copying device name

This change:
- corrects the size of destination buffer and sets it to ZE_MAX_DEVICE_NAME
- ensures that copied name is null-terminated

Signed-off-by: Patryk Wrobel <patryk.wrobel@intel.com>
This commit is contained in:
Patryk Wrobel
2022-09-08 15:32:51 +00:00
committed by Compute-Runtime-Automation
parent 788240c8ba
commit 340b578248

View File

@@ -754,7 +754,7 @@ ze_result_t DeviceImp::getProperties(ze_device_properties_t *pDeviceProperties)
} else if (driverInfo) {
name.assign(driverInfo->getDeviceName(name).c_str());
}
memcpy_s(pDeviceProperties->name, name.length(), name.c_str(), name.length());
memcpy_s(pDeviceProperties->name, ZE_MAX_DEVICE_NAME, name.c_str(), name.length() + 1);
return ZE_RESULT_SUCCESS;
}