From 52f0f80a83dfd1f751c3d6228a2c246606078974 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Sat, 9 Jun 2018 22:17:17 +0200 Subject: [PATCH] [FASTFAT] Don't add an extra \, when renaming a file at root. This fixes failures to rename a file where destination is the root of a FAT volume. CORE-10503 --- drivers/filesystems/fastfat/finfo.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/filesystems/fastfat/finfo.c b/drivers/filesystems/fastfat/finfo.c index 517d7381d61..a19c21db55d 100644 --- a/drivers/filesystems/fastfat/finfo.c +++ b/drivers/filesystems/fastfat/finfo.c @@ -787,8 +787,12 @@ VfatSetRenameInformation( } 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); }