mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
[FASTFAT]
- Fail invalid opens specifying FILE_DELETE_ON_CLOSE CORE-6931 svn path=/trunk/; revision=72196
This commit is contained in:
parent
3b70374248
commit
a93f0e73ff
1 changed files with 26 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue