[NTOSKRNL] When checking for byte offset alignment, tolerate some magic values
authorPierre Schweitzer <pierre@reactos.org>
Thu, 4 Oct 2018 05:53:12 +0000 (07:53 +0200)
committerPierre Schweitzer <pierre@reactos.org>
Thu, 4 Oct 2018 05:53:12 +0000 (07:53 +0200)
ntoskrnl/io/iomgr/iofunc.c

index c344b42..f3ad716 100644 (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;
+                        }
                     }
                 }
             }