[NTOSKRNL] When checking for byte offset alignment, tolerate some magic values

This commit is contained in:
Pierre Schweitzer 2018-10-04 07:53:12 +02:00
parent fd33402104
commit 1bd25c5c24
No known key found for this signature in database
GPG key ID: 7545556C3D585B0B

View file

@ -3656,9 +3656,15 @@ NtWriteFile(IN HANDLE FileHandle,
if ((DeviceObject->SectorSize != 0) &&
(ByteOffset->QuadPart % DeviceObject->SectorSize != 0))
{
/* Release the file object and and fail */
ObDereferenceObject(FileObject);
return STATUS_INVALID_PARAMETER;
/* Only if that's not specific values for synchronous IO */
if ((ByteOffset->QuadPart != FILE_WRITE_TO_END_OF_FILE) &&
(ByteOffset->QuadPart != FILE_USE_FILE_POINTER_POSITION ||
!BooleanFlagOn(FileObject->Flags, FO_SYNCHRONOUS_IO)))
{
/* Release the file object and and fail */
ObDereferenceObject(FileObject);
return STATUS_INVALID_PARAMETER;
}
}
}
}