https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e978ec612537ce0ffaec05eef85e8ef4c9457a0d

commit e978ec612537ce0ffaec05eef85e8ef4c9457a0d
Author:     Charles Ambrye <gi...@hotmail.com>
AuthorDate: Sat May 9 05:54:15 2020 -0700
Commit:     GitHub <nore...@github.com>
CommitDate: Sat May 9 21:54:15 2020 +0900

    [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.
---
 dll/win32/shell32/folders/CDrivesFolder.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/dll/win32/shell32/folders/CDrivesFolder.cpp 
b/dll/win32/shell32/folders/CDrivesFolder.cpp
index 482225ab607..d7246a459bb 100644
--- a/dll/win32/shell32/folders/CDrivesFolder.cpp
+++ b/dll/win32/shell32/folders/CDrivesFolder.cpp
@@ -582,6 +582,7 @@ HRESULT WINAPI CDrivesFolder::ParseDisplayName(HWND 
hwndOwner, LPBC pbc, LPOLEST
     HRESULT hr = E_INVALIDARG;
     LPCWSTR szNext = NULL;
     LPITEMIDLIST pidlTemp = NULL;
+    WCHAR volumePathName[MAX_PATH];
 
     TRACE("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n", this,
           hwndOwner, pbc, lpszDisplayName, debugstr_w (lpszDisplayName),
@@ -598,6 +599,13 @@ HRESULT WINAPI CDrivesFolder::ParseDisplayName(HWND 
hwndOwner, LPBC pbc, LPOLEST
     if (PathGetDriveNumberW(lpszDisplayName) < 0)
         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);
     if (!pidlTemp)
         return E_OUTOFMEMORY;

Reply via email to