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

This commit is contained in:
Alexandre Julliard 2009-09-10 11:06:01 +02:00
parent c1cb976b66
commit 72241b5d47
2 changed files with 20 additions and 1 deletions

View file

@ -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();
}

View file

@ -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)
{