From 964a50ca05539722c1d5d5035f5258d747be13bd Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 18 Jan 2015 13:16:34 -0800 Subject: [PATCH] Fix a couple possible buffer overruns. --- Windows/W32Util/ShellUtil.cpp | 4 ++-- Windows/W32Util/TabControl.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Windows/W32Util/ShellUtil.cpp b/Windows/W32Util/ShellUtil.cpp index f14739afd6..2f8cf7e907 100644 --- a/Windows/W32Util/ShellUtil.cpp +++ b/Windows/W32Util/ShellUtil.cpp @@ -64,8 +64,8 @@ namespace W32Util ofn.hwndOwner = _hParent; ofn.Flags = OFN_NOCHANGEDIR | OFN_EXPLORER | OFN_HIDEREADONLY; - if (_strFileName.size () != 0) - wcscpy(ofn.lpstrFile, ConvertUTF8ToWString(_strFileName).c_str()); + if (!_strFileName.empty()) + wcsncpy(ofn.lpstrFile, ConvertUTF8ToWString(_strFileName).c_str(), MAX_PATH); if (((_bLoad) ? GetOpenFileName(&ofn) : GetSaveFileName (&ofn))) { diff --git a/Windows/W32Util/TabControl.cpp b/Windows/W32Util/TabControl.cpp index 692424c63c..e537a6a28b 100644 --- a/Windows/W32Util/TabControl.cpp +++ b/Windows/W32Util/TabControl.cpp @@ -43,7 +43,7 @@ HWND TabControl::AddTabWindow(wchar_t* className, wchar_t* title, DWORD style) info.lastFocus = tabHandle; info.pageHandle = tabHandle; - wcscpy(info.title,title); + wcscpy_s(info.title,title); tabs.push_back(info); ShowTab(index); @@ -87,7 +87,7 @@ void TabControl::AddTab(HWND handle, wchar_t* title) info.lastFocus = handle; info.pageHandle = handle; - wcscpy(info.title,title); + wcscpy_s(info.title,title); tabs.push_back(info); ShowTab(index);