- Allow trailing back slashes only for directories.
- Allow trailing back slashes, if a new directory will be created.
Modified: trunk/reactos/drivers/fs/vfat/create.c
Modified: trunk/reactos/drivers/fs/vfat/vfat.h
_____
Modified: trunk/reactos/drivers/fs/vfat/create.c
--- trunk/reactos/drivers/fs/vfat/create.c 2005-11-24 18:05:53 UTC
(rev 19534)
+++ trunk/reactos/drivers/fs/vfat/create.c 2005-11-24 21:08:13 UTC
(rev 19535)
@@ -337,9 +337,11 @@
return Status;
}
+static
NTSTATUS
VfatOpenFile (
PDEVICE_EXTENSION DeviceExt,
+ PUNICODE_STRING PathNameU,
PFILE_OBJECT FileObject,
PVFATFCB* ParentFcb )
/*
@@ -348,10 +350,8 @@
{
PVFATFCB Fcb;
NTSTATUS Status;
- UNICODE_STRING PathNameU;
- WCHAR Buffer[260];
- DPRINT ("VfatOpenFile(%08lx, %08lx, '%wZ')\n", DeviceExt,
FileObject, &FileObject->FileName);
+ DPRINT ("VfatOpenFile(%08lx, '%wZ', %08lx, %08lx)\n", DeviceExt,
PathNameU, FileObject, ParentFcb);
if (FileObject->RelatedFileObject)
{
@@ -403,21 +403,10 @@
(*ParentFcb)->RefCount++;
}
- PathNameU.Buffer = Buffer;
- PathNameU.Length = 0;
- PathNameU.MaximumLength = sizeof(Buffer);
- RtlCopyUnicodeString(&PathNameU, &FileObject->FileName);
- if (PathNameU.Length > sizeof(WCHAR) &&
- PathNameU.Buffer[PathNameU.Length / sizeof(WCHAR) - 1]
== L'\\')
- {
- PathNameU.Length -= sizeof(WCHAR);
- }
- PathNameU.Buffer[PathNameU.Length / sizeof(WCHAR)] = 0;
-
/* try first to find an existing FCB in memory */
DPRINT ("Checking for existing FCB in memory\n");
- Status = vfatGetFCBForFile (DeviceExt, ParentFcb, &Fcb,
&PathNameU);
+ Status = vfatGetFCBForFile (DeviceExt, ParentFcb, &Fcb,
PathNameU);
if (!NT_SUCCESS (Status))
{
DPRINT ("Could not make a new FCB, status: %x\n",
Status);
@@ -456,6 +445,7 @@
LARGE_INTEGER AllocationSize;
BOOLEAN Dots;
UNICODE_STRING FileNameU;
+ UNICODE_STRING PathNameU;
/* Unpack the various parameters. */
Stack = IoGetCurrentIrpStackLocation (Irp);
@@ -473,6 +463,12 @@
return(STATUS_INVALID_PARAMETER);
}
+ if (RequestedOptions & FILE_DIRECTORY_FILE &&
+ RequestedOptions & FILE_NON_DIRECTORY_FILE)
+ {
+ return(STATUS_INVALID_PARAMETER);
+ }
+
/* This a open operation for the volume itself */
if (FileObject->FileName.Length == 0 &&
FileObject->RelatedFileObject == NULL)
@@ -506,12 +502,13 @@
/*
* Check for illegal characters and illegale dot sequences in
the file name
*/
- c = FileObject->FileName.Buffer + FileObject->FileName.Length /
sizeof(WCHAR);
+ PathNameU = FileObject->FileName;
+ c = PathNameU.Buffer + PathNameU.Length / sizeof(WCHAR);
last = c - 1;
Dots = TRUE;
- while (c-- > FileObject->FileName.Buffer)
+ while (c-- > PathNameU.Buffer)
{
- if (*c == L'\\' || c == FileObject->FileName.Buffer)
+ if (*c == L'\\' || c == PathNameU.Buffer)
{
if (Dots && last > c)
{
@@ -530,9 +527,22 @@
return(STATUS_OBJECT_NAME_INVALID);
}
}
+ if (FileObject->RelatedFileObject && PathNameU.Buffer[0] ==
L'\\')
+ {
+ return(STATUS_OBJECT_NAME_INVALID);
+ }
+ if (PathNameU.Length > sizeof(WCHAR) &&
PathNameU.Buffer[PathNameU.Length/sizeof(WCHAR)-1] == L'\\')
+ {
+ if (!(RequestedOptions & FILE_DIRECTORY_FILE))
+ {
+ /* FIXME: Is this the right error message? */
+ return(STATUS_OBJECT_NAME_INVALID);
+ }
+ PathNameU.Length -= sizeof(WCHAR);
+ }
/* Try opening the file. */
- Status = VfatOpenFile (DeviceExt, FileObject, &ParentFcb);
+ Status = VfatOpenFile (DeviceExt, &PathNameU, FileObject,
&ParentFcb);
/*
* If the directory containing the file to open doesn't exist
then
@@ -562,7 +572,7 @@
ULONG Attributes;
Attributes =
Stack->Parameters.Create.FileAttributes;
- vfatSplitPathName(&FileObject->FileName, NULL,
&FileNameU);
+ vfatSplitPathName(&PathNameU, NULL, &FileNameU);
Status = VfatAddEntry (DeviceExt, &FileNameU,
&pFcb, ParentFcb, RequestedOptions,
(UCHAR)(Attributes &
FILE_ATTRIBUTE_VALID_FLAGS));
vfatReleaseFCB (DeviceExt, ParentFcb);
_____
Modified: trunk/reactos/drivers/fs/vfat/vfat.h
--- trunk/reactos/drivers/fs/vfat/vfat.h 2005-11-24 18:05:53 UTC
(rev 19534)
+++ trunk/reactos/drivers/fs/vfat/vfat.h 2005-11-24 21:08:13 UTC
(rev 19535)
@@ -478,10 +478,6 @@
NTSTATUS VfatCreate (PVFAT_IRP_CONTEXT IrpContext);
-NTSTATUS VfatOpenFile (PDEVICE_EXTENSION DeviceExt,
- PFILE_OBJECT FileObject,
- PVFATFCB* parentFcb);
-
NTSTATUS FindFile (PDEVICE_EXTENSION DeviceExt,
PVFATFCB Parent,
PUNICODE_STRING FileToFindU,