diff options
| author | Shawn Hoffman <godisgovernment@gmail.com> | 2020-08-17 17:26:38 -0700 |
|---|---|---|
| committer | Shawn Hoffman <godisgovernment@gmail.com> | 2020-08-23 13:55:15 -0700 |
| commit | c22748dc38596ffc42b77496fdb62ef2c92efdcc (patch) | |
| tree | 4a549241448653332afa70053fa1ae3dafe9bd9d /Source/Core | |
| parent | b021573a7074a07e8e391526d818555caef24d3f (diff) | |
windows: fix some incorrect string lengths
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/Common/Timer.cpp | 2 | ||||
| -rw-r--r-- | Source/Core/Core/HW/EXI/BBA/TAP_Win32.cpp | 10 |
2 files changed, 7 insertions, 5 deletions
diff --git a/Source/Core/Common/Timer.cpp b/Source/Core/Common/Timer.cpp index 81fb792ff3..d33d1951eb 100644 --- a/Source/Core/Common/Timer.cpp +++ b/Source/Core/Common/Timer.cpp @@ -254,7 +254,7 @@ std::string Timer::GetDateTimeFormatted(double time) #ifdef _WIN32 wchar_t tmp[32] = {}; - wcsftime(tmp, sizeof(tmp), L"%x %X", localTime); + wcsftime(tmp, std::size(tmp), L"%x %X", localTime); return WStringToUTF8(tmp); #else char tmp[32] = {}; diff --git a/Source/Core/Core/HW/EXI/BBA/TAP_Win32.cpp b/Source/Core/Core/HW/EXI/BBA/TAP_Win32.cpp index a421484005..75b9edb5ea 100644 --- a/Source/Core/Core/HW/EXI/BBA/TAP_Win32.cpp +++ b/Source/Core/Core/HW/EXI/BBA/TAP_Win32.cpp @@ -35,7 +35,7 @@ bool IsTAPDevice(const TCHAR* guid) TCHAR net_cfg_instance_id[256]; DWORD data_type; - len = sizeof(enum_name); + len = _countof(enum_name); status = RegEnumKeyEx(netcard_key, i, enum_name, &len, nullptr, nullptr, nullptr, nullptr); if (status == ERROR_NO_MORE_ITEMS) @@ -43,7 +43,8 @@ bool IsTAPDevice(const TCHAR* guid) else if (status != ERROR_SUCCESS) return false; - _sntprintf(unit_string, sizeof(unit_string), _T("%s\\%s"), ADAPTER_KEY, enum_name); + _sntprintf(unit_string, _countof(unit_string), _T("%s\\%s"), ADAPTER_KEY, enum_name); + unit_string[_countof(unit_string) - 1] = _T('\0'); status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, unit_string, 0, KEY_READ, &unit_key); @@ -110,14 +111,15 @@ bool GetGUIDs(std::vector<std::basic_string<TCHAR>>& guids) DWORD name_type; const TCHAR name_string[] = _T("Name"); - len = sizeof(enum_name); + len = _countof(enum_name); status = RegEnumKeyEx(control_net_key, i, enum_name, &len, nullptr, nullptr, nullptr, nullptr); if (status != ERROR_SUCCESS) continue; - _sntprintf(connection_string, sizeof(connection_string), _T("%s\\%s\\Connection"), + _sntprintf(connection_string, _countof(connection_string), _T("%s\\%s\\Connection"), NETWORK_CONNECTIONS_KEY, enum_name); + connection_string[_countof(connection_string) - 1] = _T('\0'); status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, connection_string, 0, KEY_READ, &connection_key); |
