Signed-off-by: Michael Stefaniuc mstefani@winehq.org --- dlls/shlwapi/path.c | 10 ++++------ dlls/shlwapi/reg.c | 7 +++---- dlls/shlwapi/url.c | 2 +- 3 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/dlls/shlwapi/path.c b/dlls/shlwapi/path.c index ae05381b66..e24835f238 100644 --- a/dlls/shlwapi/path.c +++ b/dlls/shlwapi/path.c @@ -4217,8 +4217,6 @@ HRESULT WINAPI SHGetWebFolderFilePathW(LPCWSTR lpszFile, LPWSTR lpszPath, DWORD { static const WCHAR szWeb[] = {'\','W','e','b','\','\0'}; static const WCHAR szWebMui[] = {'m','u','i','\','%','0','4','x','\','\0'}; -#define szWebLen (sizeof(szWeb)/sizeof(WCHAR)) -#define szWebMuiLen ((sizeof(szWebMui)+1)/sizeof(WCHAR)) DWORD dwLen, dwFileLen; LANGID lidSystem, lidUser;
@@ -4231,11 +4229,11 @@ HRESULT WINAPI SHGetWebFolderFilePathW(LPCWSTR lpszFile, LPWSTR lpszPath, DWORD
dwFileLen = strlenW(lpszFile);
- if (dwLen + dwFileLen + szWebLen >= dwPathLen) + if (dwLen + dwFileLen + ARRAY_SIZE(szWeb) >= dwPathLen) return E_FAIL; /* lpszPath too short */
strcpyW(lpszPath+dwLen, szWeb); - dwLen += szWebLen; + dwLen += ARRAY_SIZE(szWeb); dwPathLen = dwPathLen - dwLen; /* Remaining space */
lidSystem = GetSystemDefaultUILanguage(); @@ -4243,11 +4241,11 @@ HRESULT WINAPI SHGetWebFolderFilePathW(LPCWSTR lpszFile, LPWSTR lpszPath, DWORD
if (lidSystem != lidUser) { - if (dwFileLen + szWebMuiLen < dwPathLen) + if (dwFileLen + ARRAY_SIZE(szWebMui) < dwPathLen) { /* Use localised content in the users UI language if present */ wsprintfW(lpszPath + dwLen, szWebMui, lidUser); - strcpyW(lpszPath + dwLen + szWebMuiLen, lpszFile); + strcpyW(lpszPath + dwLen + ARRAY_SIZE(szWebMui), lpszFile); if (PathFileExistsW(lpszPath)) return S_OK; } diff --git a/dlls/shlwapi/reg.c b/dlls/shlwapi/reg.c index a72f4c24e4..375c25429d 100644 --- a/dlls/shlwapi/reg.c +++ b/dlls/shlwapi/reg.c @@ -2426,19 +2426,18 @@ HRESULT WINAPI SHRegGetCLSIDKeyW(REFGUID guid, LPCWSTR lpszValue, BOOL bUseHKCU, 'M','i','c','r','o','s','o','f','t','\','W','i','n','d','o','w','s','\', 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\', 'E','x','p','l','o','r','e','r','\','C','L','S','I','D','\' }; -#define szClassIdKeyLen (sizeof(szClassIdKey)/sizeof(WCHAR)) WCHAR szKey[MAX_PATH]; DWORD dwRet; HKEY hkey;
/* Create the key string */ memcpy(szKey, szClassIdKey, sizeof(szClassIdKey)); - SHStringFromGUIDW(guid, szKey + szClassIdKeyLen, 39); /* Append guid */ + SHStringFromGUIDW(guid, szKey + ARRAY_SIZE(szClassIdKey), 39); /* Append guid */
if(lpszValue) { - szKey[szClassIdKeyLen + 39] = '\'; - strcpyW(szKey + szClassIdKeyLen + 40, lpszValue); /* Append value name */ + szKey[ARRAY_SIZE(szClassIdKey) + 39] = '\'; + strcpyW(szKey + ARRAY_SIZE(szClassIdKey) + 40, lpszValue); /* Append value name */ }
hkey = bUseHKCU ? HKEY_CURRENT_USER : HKEY_CLASSES_ROOT; diff --git a/dlls/shlwapi/url.c b/dlls/shlwapi/url.c index c7d717b2d7..92b4a216cb 100644 --- a/dlls/shlwapi/url.c +++ b/dlls/shlwapi/url.c @@ -2570,7 +2570,7 @@ HRESULT WINAPI MLBuildResURLW(LPCWSTR lpszLibName, HMODULE hMod, DWORD dwFlags, LPCWSTR lpszRes, LPWSTR lpszDest, DWORD dwDestLen) { static const WCHAR szRes[] = { 'r','e','s',':','/','/','\0' }; -#define szResLen ((sizeof(szRes) - sizeof(WCHAR))/sizeof(WCHAR)) + static const unsigned int szResLen = ARRAY_SIZE(szRes) - 1; HRESULT hRet = E_FAIL;
TRACE("(%s,%p,0x%08x,%s,%p,%d)\n", debugstr_w(lpszLibName), hMod, dwFlags,
On Fri, 14 Sep 2018 at 18:12, Michael Stefaniuc mstefani@winehq.org wrote:
Signed-off-by: Michael Stefaniuc mstefani@winehq.org
dlls/shlwapi/path.c | 10 ++++------ dlls/shlwapi/reg.c | 7 +++---- dlls/shlwapi/url.c | 2 +- 3 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/dlls/shlwapi/path.c b/dlls/shlwapi/path.c index ae05381b66..e24835f238 100644 --- a/dlls/shlwapi/path.c +++ b/dlls/shlwapi/path.c @@ -4217,8 +4217,6 @@ HRESULT WINAPI SHGetWebFolderFilePathW(LPCWSTR lpszFile, LPWSTR lpszPath, DWORD { static const WCHAR szWeb[] = {'\','W','e','b','\','\0'}; static const WCHAR szWebMui[] = {'m','u','i','\','%','0','4','x','\','\0'}; -#define szWebLen (sizeof(szWeb)/sizeof(WCHAR)) -#define szWebMuiLen ((sizeof(szWebMui)+1)/sizeof(WCHAR))
Doesn't this change the calculation? I don't see the +1 retained in any of the updated uses of szWebMui.
DWORD dwLen, dwFileLen; LANGID lidSystem, lidUser;
@@ -4231,11 +4229,11 @@ HRESULT WINAPI SHGetWebFolderFilePathW(LPCWSTR lpszFile, LPWSTR lpszPath, DWORD
dwFileLen = strlenW(lpszFile);
- if (dwLen + dwFileLen + szWebLen >= dwPathLen)
if (dwLen + dwFileLen + ARRAY_SIZE(szWeb) >= dwPathLen) return E_FAIL; /* lpszPath too short */
strcpyW(lpszPath+dwLen, szWeb);
- dwLen += szWebLen;
dwLen += ARRAY_SIZE(szWeb); dwPathLen = dwPathLen - dwLen; /* Remaining space */
lidSystem = GetSystemDefaultUILanguage();
@@ -4243,11 +4241,11 @@ HRESULT WINAPI SHGetWebFolderFilePathW(LPCWSTR lpszFile, LPWSTR lpszPath, DWORD
if (lidSystem != lidUser) {
- if (dwFileLen + szWebMuiLen < dwPathLen)
- if (dwFileLen + ARRAY_SIZE(szWebMui) < dwPathLen) { /* Use localised content in the users UI language if present */ wsprintfW(lpszPath + dwLen, szWebMui, lidUser);
strcpyW(lpszPath + dwLen + szWebMuiLen, lpszFile);
}strcpyW(lpszPath + dwLen + ARRAY_SIZE(szWebMui), lpszFile); if (PathFileExistsW(lpszPath)) return S_OK;
On Sep 20, 2018, at 10:00 PM, Mathew Hodson mathew.hodson@gmail.com wrote:
On Fri, 14 Sep 2018 at 18:12, Michael Stefaniuc mstefani@winehq.org wrote:
Signed-off-by: Michael Stefaniuc mstefani@winehq.org
dlls/shlwapi/path.c | 10 ++++------ dlls/shlwapi/reg.c | 7 +++---- dlls/shlwapi/url.c | 2 +- 3 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/dlls/shlwapi/path.c b/dlls/shlwapi/path.c index ae05381b66..e24835f238 100644 --- a/dlls/shlwapi/path.c +++ b/dlls/shlwapi/path.c @@ -4217,8 +4217,6 @@ HRESULT WINAPI SHGetWebFolderFilePathW(LPCWSTR lpszFile, LPWSTR lpszPath, DWORD { static const WCHAR szWeb[] = {'\','W','e','b','\','\0'}; static const WCHAR szWebMui[] = {'m','u','i','\','%','0','4','x','\','\0'}; -#define szWebLen (sizeof(szWeb)/sizeof(WCHAR)) -#define szWebMuiLen ((sizeof(szWebMui)+1)/sizeof(WCHAR))
Doesn't this change the calculation? I don't see the +1 retained in any of the updated uses of szWebMui.
No, because of integer division. sizeof(WCHAR) is 2, so the added 1 doesn't actually affect the result of the original calculation.
Now, the original may have been intended to add 1 to the overall length, but that's a different issue. Doesn't seem necessary, though. szWebMui is already null terminated and the format sequence "%04x" is the same size as the formatted value will be.
Regards, Ken