ntdll: Perform the offset checks also for a serial device.

Dmitry Timoshkov dmitry at baikal.ru
Thu Sep 19 02:10:09 CDT 2013


Please apply this patch after the 0-length read optimization removal.
---
 dlls/kernel32/tests/comm.c | 9 ---------
 dlls/ntdll/file.c          | 8 ++++++++
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/dlls/kernel32/tests/comm.c b/dlls/kernel32/tests/comm.c
index dfd148c..242b599 100644
--- a/dlls/kernel32/tests/comm.c
+++ b/dlls/kernel32/tests/comm.c
@@ -2153,20 +2153,14 @@ todo_wine
                 SetLastError(0xdeadbeef);
                 ret = ReadFile(hcom, buf, 0, &bytes, NULL);
                 ok(!ret, "ReadFile should fail\n");
-todo_wine
                 ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
                 ok(bytes == 0, "bytes %u\n", bytes);
 
                 iob.Status = -1;
                 iob.Information = -1;
                 status = pNtReadFile(hcom, 0, NULL, NULL, &iob, buf, 0, NULL, NULL);
-todo_wine
                 ok(status == STATUS_INVALID_PARAMETER, "expected STATUS_INVALID_PARAMETER, got %#x\n", status);
-                /* FIXME: Remove once Wine is fixed */
-                if (status == STATUS_PENDING) WaitForSingleObject(hcom, TIMEOUT);
-todo_wine
                 ok(iob.Status == -1, "expected -1, got %#x\n", iob.Status);
-todo_wine
                 ok(iob.Information == -1, "expected -1, got %ld\n", iob.Information);
 
                 for (i = -20; i < 20; i++)
@@ -2187,11 +2181,8 @@ todo_wine
                     }
                     else
                     {
-todo_wine
                         ok(status == STATUS_INVALID_PARAMETER, "%d: expected STATUS_INVALID_PARAMETER, got %#x\n", i, status);
-todo_wine
                         ok(iob.Status == -1, "%d: expected -1, got %#x\n", i, iob.Status);
-todo_wine
                         ok(iob.Information == -1, "%d: expected -1, got %ld\n", i, iob.Information);
                     }
                 }
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index 15e8829..75ce35c 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -632,6 +632,14 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent,
             goto done;
         }
     }
+    else if (type == FD_TYPE_SERIAL)
+    {
+        if (!(options & (FILE_SYNCHRONOUS_IO_ALERT | FILE_SYNCHRONOUS_IO_NONALERT)) && (!offset || offset->QuadPart < 0))
+        {
+            status = STATUS_INVALID_PARAMETER;
+            goto done;
+        }
+    }
 
     for (;;)
     {
-- 
1.8.3.4




More information about the wine-patches mailing list