Commit d3f09b86 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

console: Don't allow blocking read ioctls on screen buffer object.

parent 1668db80
......@@ -2981,6 +2981,7 @@ static void test_ReadConsole(HANDLE input)
{
DWORD ret, bytes;
char buf[1024];
HANDLE output;
SetLastError(0xdeadbeef);
ret = GetFileSize(input, NULL);
......@@ -3015,6 +3016,23 @@ static void test_ReadConsole(HANDLE input)
GetLastError() == ERROR_NOACCESS, /* Win 8, 10 */
"expected ERROR_NOT_ENOUGH_MEMORY, got %d\n", GetLastError());
ok(bytes == 0xdeadbeef, "expected 0xdeadbeef, got %#x\n", bytes);
output = CreateFileA("CONOUT$", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
ok(output != INVALID_HANDLE_VALUE, "Could not open console\n");
ret = ReadConsoleW(output, buf, sizeof(buf) / sizeof(WCHAR), &bytes, NULL);
ok(!ret && GetLastError() == ERROR_INVALID_HANDLE,
"ReadConsoleW returned %x(%u)\n", ret, GetLastError());
ret = ReadConsoleA(output, buf, sizeof(buf), &bytes, NULL);
ok(!ret && GetLastError() == ERROR_INVALID_HANDLE,
"ReadConsoleA returned %x(%u)\n", ret, GetLastError());
ret = ReadFile(output, buf, sizeof(buf), &bytes, NULL);
ok(!ret && GetLastError() == ERROR_INVALID_HANDLE,
"ReadFile returned %x(%u)\n", ret, GetLastError());
CloseHandle(output);
}
static void test_GetCurrentConsoleFont(HANDLE std_output)
......
......@@ -848,7 +848,8 @@ static int screen_buffer_ioctl( struct fd *fd, ioctl_code_t code, struct async *
return 1;
default:
if (!screen_buffer->input || !screen_buffer->input->server || code >> 16 != FILE_DEVICE_CONSOLE)
if (!screen_buffer->input || !screen_buffer->input->server || code >> 16 != FILE_DEVICE_CONSOLE ||
is_blocking_read_ioctl( code ))
{
set_error( STATUS_INVALID_HANDLE );
return 0;
......
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