Dmitry Timoshkov : ntdll: NtReadFile should fail for overlapped IO on files if offset is NULL.

Alexandre Julliard julliard at winehq.org
Wed Sep 4 15:08:32 CDT 2013


Module: wine
Branch: master
Commit: 2d5ecbee43f9111e8fe0c96b179d7e6c98f8416b
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=2d5ecbee43f9111e8fe0c96b179d7e6c98f8416b

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Mon Sep  2 18:30:27 2013 +0900

ntdll: NtReadFile should fail for overlapped IO on files if offset is NULL.

---

 dlls/ntdll/file.c |   35 ++++++++++++++++++++++-------------
 1 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index 3637b69..83e286e 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -604,24 +604,33 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent,
         goto done;
     }
 
-    if (type == FD_TYPE_FILE && offset && offset->QuadPart != (LONGLONG)-2 /* FILE_USE_FILE_POINTER_POSITION */ )
+    if (type == FD_TYPE_FILE)
     {
-        /* async I/O doesn't make sense on regular files */
-        while ((result = pread( unix_handle, buffer, length, offset->QuadPart )) == -1)
+        if (!(options & (FILE_SYNCHRONOUS_IO_ALERT | FILE_SYNCHRONOUS_IO_NONALERT)) && !offset)
         {
-            if (errno != EINTR)
+            status = STATUS_INVALID_PARAMETER;
+            goto done;
+        }
+
+        if (offset && offset->QuadPart != (LONGLONG)-2 /* FILE_USE_FILE_POINTER_POSITION */)
+        {
+            /* async I/O doesn't make sense on regular files */
+            while ((result = pread( unix_handle, buffer, length, offset->QuadPart )) == -1)
             {
-                status = FILE_GetNtStatus();
-                goto done;
+                if (errno != EINTR)
+                {
+                    status = FILE_GetNtStatus();
+                    goto done;
+                }
             }
-        }
-        if (options & (FILE_SYNCHRONOUS_IO_ALERT | FILE_SYNCHRONOUS_IO_NONALERT))
-            /* update file pointer position */
-            lseek( unix_handle, offset->QuadPart + result, SEEK_SET );
+            if (options & (FILE_SYNCHRONOUS_IO_ALERT | FILE_SYNCHRONOUS_IO_NONALERT))
+                /* update file pointer position */
+                lseek( unix_handle, offset->QuadPart + result, SEEK_SET );
 
-        total = result;
-        status = total ? STATUS_SUCCESS : STATUS_END_OF_FILE;
-        goto done;
+            total = result;
+            status = total ? STATUS_SUCCESS : STATUS_END_OF_FILE;
+            goto done;
+        }
     }
 
     for (;;)




More information about the wine-cvs mailing list