mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 10:35:28 +00:00
- Allow trailing back slashes only for directories.
- Allow trailing back slashes, if a new directory will be created. svn path=/trunk/; revision=19535
This commit is contained in:
parent
41909c195a
commit
33d6b7b736
2 changed files with 30 additions and 24 deletions
|
@ -337,9 +337,11 @@ FindFile (
|
|||
return Status;
|
||||
}
|
||||
|
||||
static
|
||||
NTSTATUS
|
||||
VfatOpenFile (
|
||||
PDEVICE_EXTENSION DeviceExt,
|
||||
PUNICODE_STRING PathNameU,
|
||||
PFILE_OBJECT FileObject,
|
||||
PVFATFCB* ParentFcb )
|
||||
/*
|
||||
|
@ -348,10 +350,8 @@ VfatOpenFile (
|
|||
{
|
||||
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 @@ VfatOpenFile (
|
|||
(*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 @@ VfatCreateFile ( PDEVICE_OBJECT DeviceObject, PIRP Irp )
|
|||
LARGE_INTEGER AllocationSize;
|
||||
BOOLEAN Dots;
|
||||
UNICODE_STRING FileNameU;
|
||||
UNICODE_STRING PathNameU;
|
||||
|
||||
/* Unpack the various parameters. */
|
||||
Stack = IoGetCurrentIrpStackLocation (Irp);
|
||||
|
@ -473,6 +463,12 @@ VfatCreateFile ( PDEVICE_OBJECT DeviceObject, PIRP Irp )
|
|||
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 @@ VfatCreateFile ( PDEVICE_OBJECT DeviceObject, PIRP Irp )
|
|||
/*
|
||||
* 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 @@ VfatCreateFile ( PDEVICE_OBJECT DeviceObject, PIRP Irp )
|
|||
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 @@ VfatCreateFile ( PDEVICE_OBJECT DeviceObject, PIRP Irp )
|
|||
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);
|
||||
|
|
|
@ -478,10 +478,6 @@ BOOLEAN FsdSystemTimeToDosDateTime (PDEVICE_EXTENSION DeviceExt,
|
|||
|
||||
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,
|
||||
|
|
Loading…
Reference in a new issue