mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
[NTOS:IO] Do not pass bogus file offset to the FS in NtReadFile & NtWriteFile
This commit is contained in:
parent
94f01f5b64
commit
a6c0af2e21
1 changed files with 17 additions and 0 deletions
|
@ -2776,6 +2776,14 @@ NtReadFile(IN HANDLE FileHandle,
|
|||
if (Key) CapturedKey = *Key;
|
||||
}
|
||||
|
||||
/* Check for invalid offset */
|
||||
if ((CapturedByteOffset.QuadPart < 0) && (CapturedByteOffset.QuadPart != -2))
|
||||
{
|
||||
/* -2 is FILE_USE_FILE_POINTER_POSITION */
|
||||
ObDereferenceObject(FileObject);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
/* Check for event */
|
||||
if (Event)
|
||||
{
|
||||
|
@ -3827,6 +3835,15 @@ NtWriteFile(IN HANDLE FileHandle,
|
|||
if (Key) CapturedKey = *Key;
|
||||
}
|
||||
|
||||
/* Check for invalid offset */
|
||||
if (CapturedByteOffset.QuadPart < -2)
|
||||
{
|
||||
/* -1 is FILE_WRITE_TO_END_OF_FILE */
|
||||
/* -2 is FILE_USE_FILE_POINTER_POSITION */
|
||||
ObDereferenceObject(FileObject);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
/* Check if this is an append operation */
|
||||
if ((ObjectHandleInfo.GrantedAccess &
|
||||
(FILE_APPEND_DATA | FILE_WRITE_DATA)) == FILE_APPEND_DATA)
|
||||
|
|
Loading…
Reference in a new issue