[SHELL32] Return ERROR_INVALID_DRIVE if the drive type is unknown or there is no volume mounted (#2703)

Return ERROR_INVALID_DRIVE if the drive is either unknown or unmounted.
This commit is contained in:
Charles Ambrye 2020-05-09 05:54:15 -07:00 committed by GitHub
parent e2fdfae24f
commit e978ec6125
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -582,6 +582,7 @@ HRESULT WINAPI CDrivesFolder::ParseDisplayName(HWND hwndOwner, LPBC pbc, LPOLEST
HRESULT hr = E_INVALIDARG; HRESULT hr = E_INVALIDARG;
LPCWSTR szNext = NULL; LPCWSTR szNext = NULL;
LPITEMIDLIST pidlTemp = NULL; LPITEMIDLIST pidlTemp = NULL;
WCHAR volumePathName[MAX_PATH];
TRACE("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n", this, TRACE("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n", this,
hwndOwner, pbc, lpszDisplayName, debugstr_w (lpszDisplayName), hwndOwner, pbc, lpszDisplayName, debugstr_w (lpszDisplayName),
@ -598,6 +599,13 @@ HRESULT WINAPI CDrivesFolder::ParseDisplayName(HWND hwndOwner, LPBC pbc, LPOLEST
if (PathGetDriveNumberW(lpszDisplayName) < 0) if (PathGetDriveNumberW(lpszDisplayName) < 0)
return E_INVALIDARG; return E_INVALIDARG;
/* check if this drive actually exists */
if (!GetVolumePathNameW(lpszDisplayName, volumePathName, _countof(volumePathName)) ||
GetDriveTypeW(volumePathName) < DRIVE_REMOVABLE)
{
return HRESULT_FROM_WIN32(ERROR_INVALID_DRIVE);
}
pidlTemp = _ILCreateDrive(lpszDisplayName); pidlTemp = _ILCreateDrive(lpszDisplayName);
if (!pidlTemp) if (!pidlTemp)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;