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

commit 6a683dc6d8353a27b5052a6ac8311d093bb3da98
Author:     Russell Johnson <[email protected]>
AuthorDate: Sun Jun 24 11:29:57 2018 -0700
Commit:     Hermès BÉLUSCA - MAÏTO <[email protected]>
CommitDate: Sun Jun 24 20:29:57 2018 +0200

    [SHELL32] Fixed TRASH_CanTrashFile() sending the wrong path string to 
GetVolumeInformationW() (#635)
    
    Function TRASH_CanTrashFile() would always fail because 
GetVolumeInformationW() requires only the base root path. The path (stored in 
buffer wszRootPathName) was not being stripped correctly.
    
    CORE-12340
---
 dll/win32/shell32/folders/CRecycleBin.cpp | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/dll/win32/shell32/folders/CRecycleBin.cpp 
b/dll/win32/shell32/folders/CRecycleBin.cpp
index fb8c1d8dc1..ad80c9dbc7 100644
--- a/dll/win32/shell32/folders/CRecycleBin.cpp
+++ b/dll/win32/shell32/folders/CRecycleBin.cpp
@@ -3,6 +3,7 @@
  *
  * Copyright (C) 2006 Mikolaj Zalewski
  * Copyright (C) 2009 Andrew Hill
+ * Copyright (C) 2018 Russell Johnson
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -867,6 +868,11 @@ HRESULT WINAPI CRecycleBin::Initialize(LPCITEMIDLIST 
pidlFolder, IDataObject *pd
     return S_OK;
 }
 
+/**
+ * Tests whether a file can be trashed
+ * @param wszPath Path to the file to be trash
+ * @returns TRUE if the file can be trashed, FALSE otherwise
+ */
 BOOL
 TRASH_CanTrashFile(LPCWSTR wszPath)
 {
@@ -883,12 +889,12 @@ TRASH_CanTrashFile(LPCWSTR wszPath)
         return FALSE;
     }
 
-    // Only keep the base path.
+    // Copy and retrieve the root path from get given string
     WCHAR wszRootPathName[MAX_PATH];
-    strcpyW(wszRootPathName, wszPath);
-    PathRemoveFileSpecW(wszRootPathName);
-    PathAddBackslashW(wszRootPathName);
+    StringCbCopy(wszRootPathName, sizeof(wszRootPathName), wszPath);
+    PathStripToRootW(wszRootPathName);
 
+    // Test to see if the drive is fixed (non removable)
     if (GetDriveTypeW(wszRootPathName) != DRIVE_FIXED)
     {
         /* no bitbucket on removable media */
@@ -897,7 +903,7 @@ TRASH_CanTrashFile(LPCWSTR wszPath)
 
     if (!GetVolumeInformationW(wszRootPathName, NULL, 0, &VolSerialNumber, 
&MaxComponentLength, &FileSystemFlags, NULL, 0))
     {
-        ERR("GetVolumeInformationW failed with %u\n", GetLastError());
+        ERR("GetVolumeInformationW failed with %u wszRootPathName=%s\n", 
GetLastError(), debugstr_w(wszRootPathName));
         return FALSE;
     }
 

Reply via email to