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:
Eric Pouech 2006-02-22 12:04:02 +01:00 committed by Alexandre Julliard
parent 8d845e3a1a
commit 1be2e1edef
5 changed files with 22 additions and 12 deletions

View file

@ -1259,7 +1259,7 @@ BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
DWORD dwAttributes;
STRRET strret;
TRACE_(shell)("(pidl=%p,%p)\n", pidl, debugstr_w(pszPath));
TRACE_(shell)("(pidl=%p,%p)\n", pidl, pszPath);
pdump(pidl);
if (!pidl)

View file

@ -701,6 +701,7 @@ static BOOL UNIXFS_path_to_pidl(UnixFolder *pUnixFolder, const WCHAR *path, LPIT
if (!pNextPathElement) {
SHFree(*ppidl);
*ppidl = NULL;
return FALSE;
}
pidl = ILGetNext(pidl);
@ -1753,7 +1754,7 @@ static HRESULT WINAPI UnixFolder_ISFHelper_AddFolder(ISFHelper* iface, HWND hwnd
ILFree(pidlRelative);
SHChangeNotify(SHCNE_MKDIR, SHCNF_IDLIST, pidlAbsolute, NULL);
ILFree(pidlAbsolute);
}
} else return E_FAIL;
return S_OK;
}
}

View file

@ -597,6 +597,11 @@ UINT SHELL_FindExecutable(LPCWSTR lpPath, LPCWSTR lpFile, LPCWSTR lpOperation,
filetype[filetypelen] = '\0';
TRACE("File type: %s\n", debugstr_w(filetype));
}
else
{
*filetype = '\0';
filetypelen = 0;
}
}
if (*filetype)

View file

@ -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
* 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)
{
LPITEMIDLIST pidl;
if (!pSHSimpleIDListFromPathA)
if (!pSHSimpleIDListFromPathAW)
{
HMODULE hdll=LoadLibraryA("shell32.dll");
pSHSimpleIDListFromPathA=(void*)GetProcAddress(hdll, (char*)162);
if (!pSHSimpleIDListFromPathA)
trace("SHSimpleIDListFromPathA not found in shell32.dll\n");
pSHSimpleIDListFromPathAW=(void*)GetProcAddress(hdll, (char*)162);
if (!pSHSimpleIDListFromPathAW)
trace("SHSimpleIDListFromPathAW not found in shell32.dll\n");
}
pidl=NULL;
if (pSHSimpleIDListFromPathA)
pidl=pSHSimpleIDListFromPathA(path);
/* pSHSimpleIDListFromPathAW maps to A on non NT platforms */
if (pSHSimpleIDListFromPathAW && (GetVersion() & 0x80000000))
pidl=pSHSimpleIDListFromPathAW(path);
if (!pidl)
{

View file

@ -506,9 +506,12 @@ int WINAPI PathGetDriveNumberW(LPCWSTR lpszPath)
{
TRACE ("(%s)\n",debugstr_w(lpszPath));
if (lpszPath && lpszPath[1] == ':' &&
tolowerW(*lpszPath) >= 'a' && tolowerW(*lpszPath) <= 'z')
return tolowerW(*lpszPath) - 'a';
if (lpszPath)
{
WCHAR tl = tolowerW(lpszPath[0]);
if (tl >= 'a' && tl <= 'z' && lpszPath[1] == ':')
return tl - 'a';
}
return -1;
}