[FASTFAT]

- Fail invalid opens specifying FILE_DELETE_ON_CLOSE
CORE-6931

svn path=/trunk/; revision=72196
This commit is contained in:
Thomas Faber 2016-08-11 13:25:57 +00:00
parent 3b70374248
commit a93f0e73ff

View file

@ -460,6 +460,23 @@ VfatOpenFile(
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 @@ VfatCreateFile(
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 @@ VfatCreateFile(
{
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 @@ VfatCreateFile(
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;
}
}
}