[FASTFAT] Don't add an extra \, when renaming a file at root.
authorPierre Schweitzer <pierre@reactos.org>
Sat, 9 Jun 2018 20:17:17 +0000 (22:17 +0200)
committerPierre Schweitzer <pierre@reactos.org>
Sat, 9 Jun 2018 20:17:17 +0000 (22:17 +0200)
This fixes failures to rename a file where destination is
the root of a FAT volume.

CORE-10503

drivers/filesystems/fastfat/finfo.c

index 517d738..a19c21d 100644 (file)
@@ -787,8 +787,12 @@ VfatSetRenameInformation(
         }
 
         RtlCopyUnicodeString(&NewName, &((PVFATFCB)TargetFileObject->FsContext)->PathNameU);
         }
 
         RtlCopyUnicodeString(&NewName, &((PVFATFCB)TargetFileObject->FsContext)->PathNameU);
-        NewName.Buffer[NewName.Length / sizeof(WCHAR)] = L'\\';
-        NewName.Length += sizeof(WCHAR);
+        /* If \, it's already backslash terminated, don't add it */
+        if (!vfatFCBIsRoot(TargetFileObject->FsContext))
+        {
+            NewName.Buffer[NewName.Length / sizeof(WCHAR)] = L'\\';
+            NewName.Length += sizeof(WCHAR);
+        }
         RtlAppendUnicodeStringToString(&NewName, &TargetFileObject->FileName);
     }
 
         RtlAppendUnicodeStringToString(&NewName, &TargetFileObject->FileName);
     }