api: use C locale for adapter and pool name case-insensitive comparing
Reported-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
e630c3bec1
commit
f389fd5629
@ -21,7 +21,6 @@
|
|||||||
# error Unsupported architecture
|
# error Unsupported architecture
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static _locale_t Locale;
|
|
||||||
static USHORT NativeMachine = IMAGE_FILE_PROCESS;
|
static USHORT NativeMachine = IMAGE_FILE_PROCESS;
|
||||||
|
|
||||||
WINTUN_STATUS
|
WINTUN_STATUS
|
||||||
@ -330,8 +329,6 @@ AdapterDeleteAllOurs(void)
|
|||||||
void
|
void
|
||||||
AdapterInit(void)
|
AdapterInit(void)
|
||||||
{
|
{
|
||||||
Locale = _wcreate_locale(LC_ALL, L"");
|
|
||||||
|
|
||||||
#if defined(_M_IX86) || defined(_M_ARM)
|
#if defined(_M_IX86) || defined(_M_ARM)
|
||||||
typedef BOOL(WINAPI * IsWow64Process2_t)(
|
typedef BOOL(WINAPI * IsWow64Process2_t)(
|
||||||
_In_ HANDLE hProcess, _Out_ USHORT * pProcessMachine, _Out_opt_ USHORT * pNativeMachine);
|
_In_ HANDLE hProcess, _Out_ USHORT * pProcessMachine, _Out_opt_ USHORT * pNativeMachine);
|
||||||
@ -349,12 +346,6 @@ AdapterInit(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
AdapterCleanup(void)
|
|
||||||
{
|
|
||||||
_free_locale(Locale);
|
|
||||||
}
|
|
||||||
|
|
||||||
static BOOL
|
static BOOL
|
||||||
CheckReboot(_In_ HDEVINFO DevInfo, _In_ SP_DEVINFO_DATA *DevInfoData)
|
CheckReboot(_In_ HDEVINFO DevInfo, _In_ SP_DEVINFO_DATA *DevInfoData)
|
||||||
{
|
{
|
||||||
@ -481,14 +472,14 @@ IsPoolMember(
|
|||||||
}
|
}
|
||||||
WCHAR PoolDeviceTypeName[MAX_POOL_DEVICE_TYPE];
|
WCHAR PoolDeviceTypeName[MAX_POOL_DEVICE_TYPE];
|
||||||
GetPoolDeviceTypeName(Pool, PoolDeviceTypeName);
|
GetPoolDeviceTypeName(Pool, PoolDeviceTypeName);
|
||||||
if (!_wcsicmp_l(FriendlyName, PoolDeviceTypeName, Locale) || !_wcsicmp_l(DeviceDesc, PoolDeviceTypeName, Locale))
|
if (!_wcsicmp(FriendlyName, PoolDeviceTypeName) || !_wcsicmp(DeviceDesc, PoolDeviceTypeName))
|
||||||
{
|
{
|
||||||
*IsMember = TRUE;
|
*IsMember = TRUE;
|
||||||
goto cleanupFriendlyName;
|
goto cleanupFriendlyName;
|
||||||
}
|
}
|
||||||
RemoveNumberedSuffix(FriendlyName, FriendlyName);
|
RemoveNumberedSuffix(FriendlyName, FriendlyName);
|
||||||
RemoveNumberedSuffix(DeviceDesc, DeviceDesc);
|
RemoveNumberedSuffix(DeviceDesc, DeviceDesc);
|
||||||
if (!_wcsicmp_l(FriendlyName, PoolDeviceTypeName, Locale) || !_wcsicmp_l(DeviceDesc, PoolDeviceTypeName, Locale))
|
if (!_wcsicmp(FriendlyName, PoolDeviceTypeName) || !_wcsicmp(DeviceDesc, PoolDeviceTypeName))
|
||||||
{
|
{
|
||||||
*IsMember = TRUE;
|
*IsMember = TRUE;
|
||||||
goto cleanupFriendlyName;
|
goto cleanupFriendlyName;
|
||||||
@ -630,10 +621,10 @@ WintunGetAdapter(
|
|||||||
if (NciGetConnectionName(&CfgInstanceID, Name2, sizeof(Name2), NULL) != ERROR_SUCCESS)
|
if (NciGetConnectionName(&CfgInstanceID, Name2, sizeof(Name2), NULL) != ERROR_SUCCESS)
|
||||||
continue;
|
continue;
|
||||||
Name2[_countof(Name2) - 1] = 0;
|
Name2[_countof(Name2) - 1] = 0;
|
||||||
if (_wcsicmp_l(Name, Name2, Locale))
|
if (_wcsicmp(Name, Name2))
|
||||||
{
|
{
|
||||||
RemoveNumberedSuffix(Name2, Name2);
|
RemoveNumberedSuffix(Name2, Name2);
|
||||||
if (_wcsicmp_l(Name, Name2, Locale))
|
if (_wcsicmp(Name, Name2))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,9 +75,6 @@ AdapterDeleteAllOurs(void);
|
|||||||
void
|
void
|
||||||
AdapterInit(void);
|
AdapterInit(void);
|
||||||
|
|
||||||
void
|
|
||||||
AdapterCleanup(void);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wintun adapter descriptor.
|
* Wintun adapter descriptor.
|
||||||
*/
|
*/
|
||||||
|
@ -65,7 +65,6 @@ DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ LPVOID lpvReserved)
|
|||||||
case DLL_PROCESS_DETACH:
|
case DLL_PROCESS_DETACH:
|
||||||
NciCleanup();
|
NciCleanup();
|
||||||
NamespaceCleanup();
|
NamespaceCleanup();
|
||||||
AdapterCleanup();
|
|
||||||
#ifndef _DEBUG
|
#ifndef _DEBUG
|
||||||
LocalFree(SecurityAttributesSystem.lpSecurityDescriptor);
|
LocalFree(SecurityAttributesSystem.lpSecurityDescriptor);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user