Author: hbelusca
Date: Tue Jul 12 23:00:50 2016
New Revision: 71912
URL:
http://svn.reactos.org/svn/reactos?rev=71912&view=rev
Log:
[SHELL32]
- Use StringCbCopyW
[PROGMAN]
- Use StringCbCopyW: CID #1363712.
- Don't read registry values in a registry key if we failed to open it. CID #514350.
Modified:
trunk/reactos/base/shell/progman/dialog.c
trunk/reactos/dll/win32/shell32/dialogs/dialogs.cpp
Modified: trunk/reactos/base/shell/progman/dialog.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/progman/dialog.…
==============================================================================
--- trunk/reactos/base/shell/progman/dialog.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/progman/dialog.c [iso-8859-1] Tue Jul 12 23:00:50 2016
@@ -516,7 +516,7 @@
if (IS_INTRESOURCE(lpszName))
swprintf(szName, L"%u", lpszName);
else
- wcscpy(szName, lpszName);
+ StringCbCopyW(szName, sizeof(szName), lpszName);
hIcon = (HICON)LoadImageW(hModule, lpszName, IMAGE_ICON, 32, 32, LR_DEFAULTCOLOR);
if (hIcon == NULL)
@@ -1026,6 +1026,9 @@
DWORD dwSize;
DWORD dwType;
+ ExecuteContext.hKeyPMRecentFilesList = NULL;
+ ExecuteContext.bCheckBinaryType = TRUE;
+
lRet = RegCreateKeyExW(Globals.hKeyProgMan,
L"Recent File List",
0,
@@ -1035,39 +1038,42 @@
NULL,
&ExecuteContext.hKeyPMRecentFilesList,
NULL);
-
- dwSize = sizeof(ExecuteContext.dwMaxFiles);
- lRet = RegQueryValueExW(ExecuteContext.hKeyPMRecentFilesList,
- L"Max Files",
- NULL,
- &dwType,
- (LPBYTE)&ExecuteContext.dwMaxFiles,
- &dwSize);
- if (lRet != ERROR_SUCCESS || dwType != REG_DWORD)
- {
- ExecuteContext.dwMaxFiles = 4;
+ if (lRet == ERROR_SUCCESS)
+ {
dwSize = sizeof(ExecuteContext.dwMaxFiles);
- lRet = RegSetValueExW(ExecuteContext.hKeyPMRecentFilesList,
- L"Max Files",
- 0,
- REG_DWORD,
- (LPBYTE)&ExecuteContext.dwMaxFiles,
- sizeof(ExecuteContext.dwMaxFiles));
+ lRet = RegQueryValueExW(ExecuteContext.hKeyPMRecentFilesList,
+ L"Max Files",
+ NULL,
+ &dwType,
+ (LPBYTE)&ExecuteContext.dwMaxFiles,
+ &dwSize);
+ if (lRet != ERROR_SUCCESS || dwType != REG_DWORD)
+ {
+ ExecuteContext.dwMaxFiles = 4;
+ dwSize = sizeof(ExecuteContext.dwMaxFiles);
+ lRet = RegSetValueExW(ExecuteContext.hKeyPMRecentFilesList,
+ L"Max Files",
+ 0,
+ REG_DWORD,
+ (LPBYTE)&ExecuteContext.dwMaxFiles,
+ sizeof(ExecuteContext.dwMaxFiles));
+ }
+
+ dwSize = sizeof(ExecuteContext.bCheckBinaryType);
+ lRet = RegQueryValueExW(Globals.hKeyPMSettings,
+ L"CheckBinaryType",
+ NULL,
+ &dwType,
+ (LPBYTE)&ExecuteContext.bCheckBinaryType,
+ &dwSize);
+ if (lRet != ERROR_SUCCESS || dwType != REG_DWORD)
+ {
+ ExecuteContext.bCheckBinaryType = TRUE;
+ }
}
- dwSize = sizeof(ExecuteContext.bCheckBinaryType);
- lRet = RegQueryValueExW(Globals.hKeyPMSettings,
- L"CheckBinaryType",
- NULL,
- &dwType,
- (LPBYTE)&ExecuteContext.bCheckBinaryType,
- &dwSize);
- if (lRet != ERROR_SUCCESS || dwType != REG_DWORD)
- {
- ExecuteContext.bCheckBinaryType = TRUE;
- }
-
DialogBoxParamW(Globals.hInstance, MAKEINTRESOURCEW(IDD_EXECUTE), Globals.hMainWnd,
DIALOG_EXECUTE_DlgProc, (LPARAM)&ExecuteContext);
- RegCloseKey(ExecuteContext.hKeyPMRecentFilesList);
-}
+ if (ExecuteContext.hKeyPMRecentFilesList)
+ RegCloseKey(ExecuteContext.hKeyPMRecentFilesList);
+}
Modified: trunk/reactos/dll/win32/shell32/dialogs/dialogs.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/dialogs/…
==============================================================================
--- trunk/reactos/dll/win32/shell32/dialogs/dialogs.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/dialogs/dialogs.cpp [iso-8859-1] Tue Jul 12 23:00:50
2016
@@ -64,7 +64,7 @@
if (IS_INTRESOURCE(lpszName))
swprintf(szName, L"%u", (DWORD)lpszName);
else
- wcscpy(szName, (WCHAR*)lpszName);
+ StringCbCopyW(szName, sizeof(szName), lpszName);
hIcon = LoadIconW(hModule, lpszName);
if (hIcon == NULL)