Commit 72241b5d authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Make sure that serial ioctl calls fail on non-serial handles.

parent c1cb976b
......@@ -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();
}
......@@ -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)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment