Author: pschweitzer
Date: Sun Feb 26 13:57:17 2017
New Revision: 73924
URL:
http://svn.reactos.org/svn/reactos?rev=73924&view=rev
Log:
[FASTFAT]
Addendum to r73923: merge with Thomas' patch regarding that topic.
ROSTESTS-135
Modified:
trunk/reactos/drivers/filesystems/fastfat/create.c
Modified: trunk/reactos/drivers/filesystems/fastfat/create.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/create.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/create.c [iso-8859-1] Sun Feb 26 13:57:17
2017
@@ -510,8 +510,6 @@
c = PathNameU.Buffer + PathNameU.Length / sizeof(WCHAR);
last = c - 1;
- TrailingBackslash = (*last == L'\\');
-
Dots = TRUE;
while (c-- > PathNameU.Buffer)
{
@@ -553,9 +551,11 @@
return STATUS_OBJECT_NAME_INVALID;
}
+ TrailingBackslash = FALSE;
if (PathNameU.Length > sizeof(WCHAR) &&
PathNameU.Buffer[PathNameU.Length/sizeof(WCHAR)-1] == L'\\')
{
PathNameU.Length -= sizeof(WCHAR);
+ TrailingBackslash = TRUE;
}
if (PathNameU.Length > sizeof(WCHAR) &&
PathNameU.Buffer[PathNameU.Length/sizeof(WCHAR)-1] == L'\\')
@@ -700,14 +700,16 @@
RequestedDisposition == FILE_OVERWRITE_IF ||
RequestedDisposition == FILE_SUPERSEDE)
{
- if (TrailingBackslash & !BooleanFlagOn(RequestedOptions,
FILE_DIRECTORY_FILE))
- {
- return STATUS_OBJECT_NAME_INVALID;
- }
-
Attributes = Stack->Parameters.Create.FileAttributes &
~FILE_ATTRIBUTE_NORMAL;
if (!BooleanFlagOn(RequestedOptions, FILE_DIRECTORY_FILE))
+ {
+ if (TrailingBackslash)
+ {
+ vfatReleaseFCB(DeviceExt, ParentFcb);
+ return STATUS_OBJECT_NAME_INVALID;
+ }
Attributes |= FILE_ATTRIBUTE_ARCHIVE;
+ }
vfatSplitPathName(&PathNameU, NULL, &FileNameU);
Status = VfatAddEntry(DeviceExt, &FileNameU, &pFcb, ParentFcb,
RequestedOptions,
(UCHAR)FlagOn(Attributes, FILE_ATTRIBUTE_VALID_FLAGS),
NULL);
@@ -756,15 +758,19 @@
vfatReleaseFCB(DeviceExt, ParentFcb);
}
+ pFcb = FileObject->FsContext;
+
/* Otherwise fail if the caller wanted to create a new file */
if (RequestedDisposition == FILE_CREATE)
{
+ VfatCloseFile(DeviceExt, FileObject);
+ if (TrailingBackslash && !vfatFCBIsDirectory(pFcb))
+ {
+ return STATUS_OBJECT_NAME_INVALID;
+ }
Irp->IoStatus.Information = FILE_EXISTS;
- VfatCloseFile(DeviceExt, FileObject);
return STATUS_OBJECT_NAME_COLLISION;
}
-
- pFcb = FileObject->FsContext;
if (pFcb->OpenHandleCount != 0)
{
@@ -795,7 +801,7 @@
VfatCloseFile (DeviceExt, FileObject);
return STATUS_NOT_A_DIRECTORY;
}
- if (!vfatFCBIsDirectory(pFcb) && TrailingBackslash)
+ if (TrailingBackslash && !vfatFCBIsDirectory(pFcb))
{
VfatCloseFile (DeviceExt, FileObject);
return STATUS_OBJECT_NAME_INVALID;