shell32: Fixes for bugs found by valgrind on shell32 tests harness.
- read strings from left to right (PathGetDriveNumberW) - don't access buffers before they are filled (SHGetPathFromIDListW) - fill buffers & variables on all paths (SHELL_FindExecutable) - handle error condition (unix_fs) - don't shoot in the blind for AW APIs (tests/shelllink.c)
This commit is contained in:
parent
8d845e3a1a
commit
1be2e1edef
|
@ -1259,7 +1259,7 @@ BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
|
||||||
DWORD dwAttributes;
|
DWORD dwAttributes;
|
||||||
STRRET strret;
|
STRRET strret;
|
||||||
|
|
||||||
TRACE_(shell)("(pidl=%p,%p)\n", pidl, debugstr_w(pszPath));
|
TRACE_(shell)("(pidl=%p,%p)\n", pidl, pszPath);
|
||||||
pdump(pidl);
|
pdump(pidl);
|
||||||
|
|
||||||
if (!pidl)
|
if (!pidl)
|
||||||
|
|
|
@ -701,6 +701,7 @@ static BOOL UNIXFS_path_to_pidl(UnixFolder *pUnixFolder, const WCHAR *path, LPIT
|
||||||
|
|
||||||
if (!pNextPathElement) {
|
if (!pNextPathElement) {
|
||||||
SHFree(*ppidl);
|
SHFree(*ppidl);
|
||||||
|
*ppidl = NULL;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
pidl = ILGetNext(pidl);
|
pidl = ILGetNext(pidl);
|
||||||
|
@ -1753,7 +1754,7 @@ static HRESULT WINAPI UnixFolder_ISFHelper_AddFolder(ISFHelper* iface, HWND hwnd
|
||||||
ILFree(pidlRelative);
|
ILFree(pidlRelative);
|
||||||
SHChangeNotify(SHCNE_MKDIR, SHCNF_IDLIST, pidlAbsolute, NULL);
|
SHChangeNotify(SHCNE_MKDIR, SHCNF_IDLIST, pidlAbsolute, NULL);
|
||||||
ILFree(pidlAbsolute);
|
ILFree(pidlAbsolute);
|
||||||
}
|
} else return E_FAIL;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -597,6 +597,11 @@ UINT SHELL_FindExecutable(LPCWSTR lpPath, LPCWSTR lpFile, LPCWSTR lpOperation,
|
||||||
filetype[filetypelen] = '\0';
|
filetype[filetypelen] = '\0';
|
||||||
TRACE("File type: %s\n", debugstr_w(filetype));
|
TRACE("File type: %s\n", debugstr_w(filetype));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*filetype = '\0';
|
||||||
|
filetypelen = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*filetype)
|
if (*filetype)
|
||||||
|
|
|
@ -43,23 +43,24 @@ static const WCHAR notafile[]= { 'C',':','\\','n','o','n','e','x','i','s','t','e
|
||||||
* SHSimpleIDListFromPathA does not work on NT4. But if we call both we
|
* SHSimpleIDListFromPathA does not work on NT4. But if we call both we
|
||||||
* get what we want on all platforms.
|
* get what we want on all platforms.
|
||||||
*/
|
*/
|
||||||
static LPITEMIDLIST (WINAPI *pSHSimpleIDListFromPathA)(LPCSTR)=NULL;
|
static LPITEMIDLIST (WINAPI *pSHSimpleIDListFromPathAW)(LPCVOID);
|
||||||
|
|
||||||
static LPITEMIDLIST path_to_pidl(const char* path)
|
static LPITEMIDLIST path_to_pidl(const char* path)
|
||||||
{
|
{
|
||||||
LPITEMIDLIST pidl;
|
LPITEMIDLIST pidl;
|
||||||
|
|
||||||
if (!pSHSimpleIDListFromPathA)
|
if (!pSHSimpleIDListFromPathAW)
|
||||||
{
|
{
|
||||||
HMODULE hdll=LoadLibraryA("shell32.dll");
|
HMODULE hdll=LoadLibraryA("shell32.dll");
|
||||||
pSHSimpleIDListFromPathA=(void*)GetProcAddress(hdll, (char*)162);
|
pSHSimpleIDListFromPathAW=(void*)GetProcAddress(hdll, (char*)162);
|
||||||
if (!pSHSimpleIDListFromPathA)
|
if (!pSHSimpleIDListFromPathAW)
|
||||||
trace("SHSimpleIDListFromPathA not found in shell32.dll\n");
|
trace("SHSimpleIDListFromPathAW not found in shell32.dll\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
pidl=NULL;
|
pidl=NULL;
|
||||||
if (pSHSimpleIDListFromPathA)
|
/* pSHSimpleIDListFromPathAW maps to A on non NT platforms */
|
||||||
pidl=pSHSimpleIDListFromPathA(path);
|
if (pSHSimpleIDListFromPathAW && (GetVersion() & 0x80000000))
|
||||||
|
pidl=pSHSimpleIDListFromPathAW(path);
|
||||||
|
|
||||||
if (!pidl)
|
if (!pidl)
|
||||||
{
|
{
|
||||||
|
|
|
@ -506,9 +506,12 @@ int WINAPI PathGetDriveNumberW(LPCWSTR lpszPath)
|
||||||
{
|
{
|
||||||
TRACE ("(%s)\n",debugstr_w(lpszPath));
|
TRACE ("(%s)\n",debugstr_w(lpszPath));
|
||||||
|
|
||||||
if (lpszPath && lpszPath[1] == ':' &&
|
if (lpszPath)
|
||||||
tolowerW(*lpszPath) >= 'a' && tolowerW(*lpszPath) <= 'z')
|
{
|
||||||
return tolowerW(*lpszPath) - 'a';
|
WCHAR tl = tolowerW(lpszPath[0]);
|
||||||
|
if (tl >= 'a' && tl <= 'z' && lpszPath[1] == ':')
|
||||||
|
return tl - 'a';
|
||||||
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue