Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/jp7677/dxvk-nvapi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Peters <jp7677@gmail.com>2022-03-25 21:53:56 +0300
committerJens Peters <jp7677@gmail.com>2022-03-26 21:23:34 +0300
commit7e53c90d58003a30ad1e4db3092ecf5c660901b8 (patch)
tree4ff57a4cf384b80a39c5d2c6043cf4b29e578f3a
parentb7d7bb6f4a5d7e6df2dc3c510260aed2fd48cffc (diff)
nvapi: Copy into shortstring without writing out of bounds
DXVK_NVAPI_VERSION comes from the VCS tag, we should not asume that it is always short. The same applies for adapter and display names.
-rw-r--r--src/nvapi.cpp10
-rw-r--r--src/nvapi_gpu.cpp6
-rw-r--r--src/nvapi_sys.cpp2
3 files changed, 9 insertions, 9 deletions
diff --git a/src/nvapi.cpp b/src/nvapi.cpp
index 3b3ee45..eaf1928 100644
--- a/src/nvapi.cpp
+++ b/src/nvapi.cpp
@@ -122,8 +122,8 @@ extern "C" {
// Ignore hNvDisplay and query the first adapter
pVersion->drvVersion = nvapiAdapterRegistry->GetAdapter()->GetDriverVersion();
pVersion->bldChangeListNum = 0;
- strcpy(pVersion->szBuildBranchString, str::format(NVAPI_VERSION, "_", DXVK_NVAPI_VERSION).c_str());
- strcpy(pVersion->szAdapterString, nvapiAdapterRegistry->GetAdapter()->GetDeviceName().c_str());
+ str::tonvss(pVersion->szBuildBranchString, str::format(NVAPI_VERSION, "_", DXVK_NVAPI_VERSION));
+ str::tonvss(pVersion->szAdapterString, nvapiAdapterRegistry->GetAdapter()->GetDeviceName());
return Ok(n);
}
@@ -202,7 +202,7 @@ extern "C" {
if (!nvapiAdapterRegistry->IsOutput(output))
return ExpectedDisplayHandle(n);
- strcpy(szDisplayName, output->GetDeviceName().c_str());
+ str::tonvss(szDisplayName, output->GetDeviceName());
return Ok(n);
}
@@ -213,7 +213,7 @@ extern "C" {
if (szDesc == nullptr)
return InvalidArgument(n);
- strcpy(szDesc, "DXVK_NVAPI");
+ str::tonvss(szDesc, "DXVK_NVAPI");
return Ok(n);
}
@@ -225,7 +225,7 @@ extern "C" {
return InvalidArgument(n);
auto error = fromErrorNr(nr);
- strcpy(szDesc, error.c_str());
+ str::tonvss(szDesc, error);
return Ok(str::format(n, " (", nr, "/", error, ")"));
}
diff --git a/src/nvapi_gpu.cpp b/src/nvapi_gpu.cpp
index 1aa0899..23aa298 100644
--- a/src/nvapi_gpu.cpp
+++ b/src/nvapi_gpu.cpp
@@ -58,7 +58,7 @@ extern "C" {
if (!nvapiAdapterRegistry->IsAdapter(adapter))
return ExpectedPhysicalGpuHandle(n);
- strcpy(szName, adapter->GetDeviceName().c_str());
+ str::tonvss(szName, adapter->GetDeviceName());
return Ok(n);
}
@@ -298,7 +298,7 @@ extern "C" {
return ExpectedPhysicalGpuHandle(n);
if (!adapter->HasNvml() || !adapter->HasNvmlDevice()) {
- strcpy(szBiosRevision, "N/A");
+ str::tonvss(szBiosRevision, "N/A");
return Ok(n);
}
@@ -306,7 +306,7 @@ extern "C" {
auto result = adapter->GetNvmlDeviceVbiosVersion(version, NVML_DEVICE_INFOROM_VERSION_BUFFER_SIZE);
switch (result) {
case NVML_SUCCESS:
- strcpy(szBiosRevision, version);
+ str::tonvss(szBiosRevision, version);
return Ok(n);
case NVML_ERROR_NOT_SUPPORTED:
return NotSupported(n);
diff --git a/src/nvapi_sys.cpp b/src/nvapi_sys.cpp
index 3d99dd4..1ce2a64 100644
--- a/src/nvapi_sys.cpp
+++ b/src/nvapi_sys.cpp
@@ -31,7 +31,7 @@ extern "C" {
return InvalidArgument(n);
*pDriverVersion = nvapiAdapterRegistry->GetAdapter()->GetDriverVersion();
- strcpy(szBuildBranchString, str::format(NVAPI_VERSION, "_", DXVK_NVAPI_VERSION).c_str());
+ str::tonvss(szBuildBranchString, str::format(NVAPI_VERSION, "_", DXVK_NVAPI_VERSION));
return Ok(n);
}