Alexandre Julliard : ntdll: Make sure that serial ioctl calls fail on non-serial handles.
Alexandre Julliard
julliard at winehq.org
Thu Sep 10 09:08:03 CDT 2009
Module: wine
Branch: master
Commit: 72241b5d47ddd5a4373f206502e876e7ef13683d
URL: http://source.winehq.org/git/wine.git/?a=commit;h=72241b5d47ddd5a4373f206502e876e7ef13683d
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Sep 10 11:06:01 2009 +0200
ntdll: Make sure that serial ioctl calls fail on non-serial handles.
---
dlls/kernel32/tests/comm.c | 10 ++++++++++
dlls/ntdll/serial.c | 11 ++++++++++-
2 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/dlls/kernel32/tests/comm.c b/dlls/kernel32/tests/comm.c
index 2fb95cd..3d0d17b 100644
--- a/dlls/kernel32/tests/comm.c
+++ b/dlls/kernel32/tests/comm.c
@@ -1643,6 +1643,15 @@ static void test_WaitBreak(HANDLE hcom)
ok(ClearCommBreak(hcom), "ClearCommBreak failed\n");
}
+static void test_stdio(void)
+{
+ DCB dcb;
+
+ /* cygwin tries this to determine the stdin handle type */
+ ok( !GetCommState( GetStdHandle(STD_INPUT_HANDLE), &dcb ), "GetCommState succeeded on stdin\n" );
+ ok( GetLastError() == ERROR_INVALID_HANDLE, "got error %u\n", GetLastError() );
+}
+
START_TEST(comm)
{
HANDLE hcom;
@@ -1735,4 +1744,5 @@ START_TEST(comm)
test_WaitBreak(hcom);
CloseHandle(hcom);
}
+ test_stdio();
}
diff --git a/dlls/ntdll/serial.c b/dlls/ntdll/serial.c
index 2aff6fc..1936428 100644
--- a/dlls/ntdll/serial.c
+++ b/dlls/ntdll/serial.c
@@ -1110,8 +1110,17 @@ static inline NTSTATUS io_control(HANDLE hDevice,
if (dwIoControlCode != IOCTL_SERIAL_GET_TIMEOUTS &&
dwIoControlCode != IOCTL_SERIAL_SET_TIMEOUTS)
- if ((status = server_get_unix_fd( hDevice, access, &fd, &needs_close, NULL, NULL )))
+ {
+ enum server_fd_type type;
+ if ((status = server_get_unix_fd( hDevice, access, &fd, &needs_close, &type, NULL )))
+ goto error;
+ if (type != FD_TYPE_SERIAL)
+ {
+ if (needs_close) close( fd );
+ status = STATUS_OBJECT_TYPE_MISMATCH;
goto error;
+ }
+ }
switch (dwIoControlCode)
{
More information about the wine-cvs
mailing list