Author: tfaber
Date: Thu Aug 11 13:25:57 2016
New Revision: 72196
URL:
http://svn.reactos.org/svn/reactos?rev=72196&view=rev
Log:
[FASTFAT]
- Fail invalid opens specifying FILE_DELETE_ON_CLOSE
CORE-6931
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] Thu Aug 11 13:25:57
2016
@@ -460,6 +460,23 @@
return STATUS_ACCESS_DENIED;
}
+ if ((*Fcb->Attributes & FILE_ATTRIBUTE_READONLY) &&
+ (RequestedOptions & FILE_DELETE_ON_CLOSE))
+ {
+ vfatReleaseFCB(DeviceExt, Fcb);
+ return STATUS_CANNOT_DELETE;
+ }
+
+ if ((vfatFCBIsRoot(Fcb) ||
+ (Fcb->LongNameU.Length == sizeof(WCHAR) &&
Fcb->LongNameU.Buffer[0] == L'.') ||
+ (Fcb->LongNameU.Length == 2 * sizeof(WCHAR) &&
Fcb->LongNameU.Buffer[0] == L'.' && Fcb->LongNameU.Buffer[1] ==
L'.')) &&
+ (RequestedOptions & FILE_DELETE_ON_CLOSE))
+ {
+ // we cannot delete a '.', '..' or the root directory
+ vfatReleaseFCB(DeviceExt, Fcb);
+ return STATUS_CANNOT_DELETE;
+ }
+
DPRINT("Attaching FCB to fileObject\n");
Status = vfatAttachFCBToFileObject(DeviceExt, Fcb, FileObject);
if (!NT_SUCCESS(Status))
@@ -552,6 +569,11 @@
return STATUS_INVALID_PARAMETER;
}
+ if (RequestedOptions & FILE_DELETE_ON_CLOSE)
+ {
+ return STATUS_CANNOT_DELETE;
+ }
+
pFcb = DeviceExt->VolumeFcb;
if (pFcb->OpenHandleCount == 0)
@@ -870,7 +892,8 @@
{
if (Stack->Parameters.Create.SecurityContext->DesiredAccess &
FILE_WRITE_DATA ||
RequestedDisposition == FILE_OVERWRITE ||
- RequestedDisposition == FILE_OVERWRITE_IF)
+ RequestedDisposition == FILE_OVERWRITE_IF ||
+ (RequestedOptions & FILE_DELETE_ON_CLOSE))
{
if (!MmFlushImageSection(&pFcb->SectionObjectPointers,
MmFlushForWrite))
{
@@ -878,7 +901,8 @@
DPRINT1("%d %d %d\n",
Stack->Parameters.Create.SecurityContext->DesiredAccess & FILE_WRITE_DATA,
RequestedDisposition == FILE_OVERWRITE, RequestedDisposition
== FILE_OVERWRITE_IF);
VfatCloseFile (DeviceExt, FileObject);
- return STATUS_SHARING_VIOLATION;
+ return (RequestedOptions & FILE_DELETE_ON_CLOSE) ?
STATUS_CANNOT_DELETE
+ :
STATUS_SHARING_VIOLATION;
}
}
}