api: revise str/memcpy

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2020-07-28 12:51:20 +02:00 committed by Jason A. Donenfeld
parent af937e52eb
commit 295591046f

View File

@ -476,7 +476,7 @@ CreateAdapterData(
goto cleanupAdapter;
}
wcscpy_s((*Adapter)->Pool, _countof((*Adapter)->Pool), Pool);
wcsncpy_s((*Adapter)->Pool, _countof((*Adapter)->Pool), Pool, _TRUNCATE);
Result = ERROR_SUCCESS;
cleanupAdapter:
@ -689,7 +689,7 @@ WintunSetAdapterName(_In_ const WINTUN_ADAPTER *Adapter, _In_z_count_c_(MAX_ADAP
DWORD Result;
const int MaxSuffix = 1000;
WCHAR AvailableName[MAX_ADAPTER_NAME];
wcscpy_s(AvailableName, _countof(AvailableName), Name);
wcsncpy_s(AvailableName, _countof(AvailableName), Name, _TRUNCATE);
for (int i = 0;; ++i)
{
Result = NciSetConnectionName(&Adapter->CfgInstanceID, AvailableName);
@ -755,7 +755,7 @@ WintunSetAdapterName(_In_ const WINTUN_ADAPTER *Adapter, _In_z_count_c_(MAX_ADAP
void WINAPI
WintunGetAdapterGUID(_In_ const WINTUN_ADAPTER *Adapter, _Out_ GUID *Guid)
{
memcpy_s(Guid, sizeof(*Guid), &Adapter->CfgInstanceID, sizeof(Adapter->CfgInstanceID));
memcpy(Guid, &Adapter->CfgInstanceID, sizeof(GUID));
}
/**