Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
0272da5a
Commit
0272da5a
authored
Jan 03, 2011
by
Andrew Nguyen
Committed by
Alexandre Julliard
Jan 04, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Improve parameter validation for WriteConsoleInputW.
parent
3501b0a5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
106 additions
and
3 deletions
+106
-3
console.c
dlls/kernel32/console.c
+15
-3
console.c
dlls/kernel32/tests/console.c
+91
-0
No files found.
dlls/kernel32/console.c
View file @
0272da5a
...
...
@@ -504,20 +504,32 @@ BOOL WINAPI WriteConsoleInputA( HANDLE handle, const INPUT_RECORD *buffer,
BOOL
WINAPI
WriteConsoleInputW
(
HANDLE
handle
,
const
INPUT_RECORD
*
buffer
,
DWORD
count
,
LPDWORD
written
)
{
DWORD
events_written
=
0
;
BOOL
ret
;
TRACE
(
"(%p,%p,%d,%p)
\n
"
,
handle
,
buffer
,
count
,
written
);
if
(
written
)
*
written
=
0
;
if
(
count
>
0
&&
!
buffer
)
{
SetLastError
(
ERROR_INVALID_ACCESS
);
return
FALSE
;
}
SERVER_START_REQ
(
write_console_input
)
{
req
->
handle
=
console_handle_unmap
(
handle
);
wine_server_add_data
(
req
,
buffer
,
count
*
sizeof
(
INPUT_RECORD
)
);
if
((
ret
=
!
wine_server_call_err
(
req
))
&&
written
)
*
written
=
reply
->
written
;
if
((
ret
=
!
wine_server_call_err
(
req
)))
events_
written
=
reply
->
written
;
}
SERVER_END_REQ
;
if
(
written
)
*
written
=
events_written
;
else
{
SetLastError
(
ERROR_INVALID_ACCESS
);
ret
=
FALSE
;
}
return
ret
;
}
...
...
dlls/kernel32/tests/console.c
View file @
0272da5a
...
...
@@ -1221,6 +1221,96 @@ static void test_GetNumberOfConsoleInputEvents(HANDLE input_handle)
ok
(
count
!=
0xdeadbeef
,
"Expected output count to initialized
\n
"
);
}
static
void
test_WriteConsoleInputW
(
HANDLE
input_handle
)
{
INPUT_RECORD
event
,
temp
;
MOUSE_EVENT_RECORD
mouse_event
=
{
{
0
,
0
},
0
,
0
,
MOUSE_MOVED
};
DWORD
count
;
BOOL
ret
;
int
i
;
const
struct
{
HANDLE
handle
;
const
INPUT_RECORD
*
buffer
;
DWORD
count
;
LPDWORD
written
;
DWORD
expected_count
;
DWORD
last_error
;
int
win7_crash
;
}
invalid_table
[]
=
{
{
NULL
,
NULL
,
0
,
NULL
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
,
1
},
{
NULL
,
NULL
,
0
,
&
count
,
0
,
ERROR_INVALID_HANDLE
},
{
NULL
,
NULL
,
1
,
NULL
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
},
{
NULL
,
NULL
,
1
,
&
count
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
},
{
NULL
,
&
event
,
0
,
NULL
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
,
1
},
{
NULL
,
&
event
,
0
,
&
count
,
0
,
ERROR_INVALID_HANDLE
},
{
NULL
,
&
event
,
1
,
NULL
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
,
1
},
{
NULL
,
&
event
,
1
,
&
count
,
0
,
ERROR_INVALID_HANDLE
},
{
INVALID_HANDLE_VALUE
,
NULL
,
0
,
NULL
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
,
1
},
{
INVALID_HANDLE_VALUE
,
NULL
,
0
,
&
count
,
0
,
ERROR_INVALID_HANDLE
},
{
INVALID_HANDLE_VALUE
,
NULL
,
1
,
NULL
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
},
{
INVALID_HANDLE_VALUE
,
NULL
,
1
,
&
count
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
},
{
INVALID_HANDLE_VALUE
,
&
event
,
0
,
NULL
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
,
1
},
{
INVALID_HANDLE_VALUE
,
&
event
,
0
,
&
count
,
0
,
ERROR_INVALID_HANDLE
},
{
INVALID_HANDLE_VALUE
,
&
event
,
1
,
NULL
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
,
1
},
{
INVALID_HANDLE_VALUE
,
&
event
,
1
,
&
count
,
0
,
ERROR_INVALID_HANDLE
},
{
input_handle
,
NULL
,
0
,
NULL
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
,
1
},
{
input_handle
,
NULL
,
1
,
NULL
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
},
{
input_handle
,
NULL
,
1
,
&
count
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
},
{
input_handle
,
&
event
,
0
,
NULL
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
,
1
},
{
input_handle
,
&
event
,
1
,
NULL
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
,
1
},
};
event
.
EventType
=
MOUSE_EVENT
;
event
.
Event
.
MouseEvent
=
mouse_event
;
for
(
i
=
0
;
i
<
sizeof
(
invalid_table
)
/
sizeof
(
invalid_table
[
0
]);
i
++
)
{
if
(
invalid_table
[
i
].
win7_crash
)
continue
;
SetLastError
(
0xdeadbeef
);
if
(
invalid_table
[
i
].
written
)
count
=
0xdeadbeef
;
ret
=
WriteConsoleInputW
(
invalid_table
[
i
].
handle
,
invalid_table
[
i
].
buffer
,
invalid_table
[
i
].
count
,
invalid_table
[
i
].
written
);
ok
(
!
ret
,
"[%d] Expected WriteConsoleInputW to return FALSE, got %d
\n
"
,
i
,
ret
);
if
(
invalid_table
[
i
].
written
)
{
ok
(
count
==
invalid_table
[
i
].
expected_count
,
"[%d] Expected output count to be %u, got %u
\n
"
,
i
,
invalid_table
[
i
].
expected_count
,
count
);
}
ok
(
GetLastError
()
==
invalid_table
[
i
].
last_error
,
"[%d] Expected last error to be %u, got %u
\n
"
,
i
,
invalid_table
[
i
].
last_error
,
GetLastError
());
}
count
=
0xdeadbeef
;
ret
=
WriteConsoleInputW
(
input_handle
,
NULL
,
0
,
&
count
);
ok
(
ret
==
TRUE
,
"Expected WriteConsoleInputW to return TRUE, got %d
\n
"
,
ret
);
ok
(
count
==
0
,
"Expected count to be 0, got %u
\n
"
,
count
);
count
=
0xdeadbeef
;
ret
=
WriteConsoleInputW
(
input_handle
,
&
event
,
0
,
&
count
);
ok
(
ret
==
TRUE
,
"Expected WriteConsoleInputW to return TRUE, got %d
\n
"
,
ret
);
ok
(
count
==
0
,
"Expected count to be 0, got %u
\n
"
,
count
);
count
=
0xdeadbeef
;
ret
=
WriteConsoleInputW
(
input_handle
,
&
event
,
1
,
&
count
);
ok
(
ret
==
TRUE
,
"Expected WriteConsoleInputW to return TRUE, got %d
\n
"
,
ret
);
ok
(
count
==
1
,
"Expected count to be 1, got %u
\n
"
,
count
);
/* Discard the queued input event by reading it. */
count
=
0xdeadbeef
;
ret
=
ReadConsoleInputW
(
input_handle
,
&
temp
,
1
,
&
count
);
ok
(
ret
==
TRUE
,
"Expected ReadConsoleInputW to return TRUE, got %d
\n
"
,
ret
);
ok
(
count
==
1
,
"Expected count to be 1, got %u
\n
"
,
count
);
}
START_TEST
(
console
)
{
HANDLE
hConIn
,
hConOut
;
...
...
@@ -1275,4 +1365,5 @@ START_TEST(console)
test_VerifyConsoleIoHandle
(
hConOut
);
test_GetSetStdHandle
();
test_GetNumberOfConsoleInputEvents
(
hConIn
);
test_WriteConsoleInputW
(
hConIn
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment