Dmitry Timoshkov : ntdll: Perform the offset checks in NtWriteFile also for a serial device.
Alexandre Julliard
julliard at winehq.org
Wed Sep 25 14:18:00 CDT 2013
Module: wine
Branch: master
Commit: 2ffd28cff7012c15ed3e181120fcb96148d0398d
URL: http://source.winehq.org/git/wine.git/?a=commit;h=2ffd28cff7012c15ed3e181120fcb96148d0398d
Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date: Wed Sep 25 13:03:25 2013 +0900
ntdll: Perform the offset checks in NtWriteFile also for a serial device.
---
dlls/kernel32/tests/comm.c | 10 ----------
dlls/ntdll/file.c | 9 +++++++++
2 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/dlls/kernel32/tests/comm.c b/dlls/kernel32/tests/comm.c
index 242b599..4e7fee5 100644
--- a/dlls/kernel32/tests/comm.c
+++ b/dlls/kernel32/tests/comm.c
@@ -830,9 +830,7 @@ static void test_waittxempty(void)
SetLastError(0xdeadbeef);
res = WriteFile(hcom, tbuf, sizeof(tbuf), &bytes, NULL);
-todo_wine
ok(!res, "WriteFile on an overlapped handle without ovl structure should fail\n");
-todo_wine
ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
S(U(ovl_write)).Offset = 0;
@@ -2057,20 +2055,15 @@ static void test_read_write(void)
bytes = 0xdeadbeef;
SetLastError(0xdeadbeef);
ret = WriteFile(hcom, atz, 0, &bytes, NULL);
-todo_wine
ok(!ret, "WriteFile 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 = pNtWriteFile(hcom, 0, NULL, NULL, &iob, atz, 0, NULL, NULL);
-todo_wine
ok(status == STATUS_INVALID_PARAMETER, "expected STATUS_INVALID_PARAMETER, got %#x\n", status);
-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++)
@@ -2087,11 +2080,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 75ce35c..1cc8f87 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -1016,6 +1016,15 @@ NTSTATUS WINAPI NtWriteFile(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 && offset->QuadPart != (LONGLONG)-1 /* FILE_WRITE_TO_END_OF_FILE */)))
+ {
+ status = STATUS_INVALID_PARAMETER;
+ goto done;
+ }
+ }
for (;;)
{
More information about the wine-cvs
mailing list