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
c905b7e7
Commit
c905b7e7
authored
Jan 11, 2011
by
Andrew Nguyen
Committed by
Alexandre Julliard
Jan 11, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Improve parameter validation for ReadConsoleOutputCharacterW.
parent
54684cf6
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
94 additions
and
3 deletions
+94
-3
console.c
dlls/kernel32/console.c
+9
-3
console.c
dlls/kernel32/tests/console.c
+85
-0
No files found.
dlls/kernel32/console.c
View file @
c905b7e7
...
@@ -862,6 +862,14 @@ BOOL WINAPI ReadConsoleOutputCharacterW( HANDLE hConsoleOutput, LPWSTR buffer, D
...
@@ -862,6 +862,14 @@ BOOL WINAPI ReadConsoleOutputCharacterW( HANDLE hConsoleOutput, LPWSTR buffer, D
TRACE
(
"(%p,%p,%d,%dx%d,%p)
\n
"
,
hConsoleOutput
,
buffer
,
count
,
coord
.
X
,
coord
.
Y
,
read_count
);
TRACE
(
"(%p,%p,%d,%dx%d,%p)
\n
"
,
hConsoleOutput
,
buffer
,
count
,
coord
.
X
,
coord
.
Y
,
read_count
);
if
(
!
read_count
)
{
SetLastError
(
ERROR_INVALID_ACCESS
);
return
FALSE
;
}
*
read_count
=
0
;
SERVER_START_REQ
(
read_console_output
)
SERVER_START_REQ
(
read_console_output
)
{
{
req
->
handle
=
console_handle_unmap
(
hConsoleOutput
);
req
->
handle
=
console_handle_unmap
(
hConsoleOutput
);
...
@@ -871,9 +879,7 @@ BOOL WINAPI ReadConsoleOutputCharacterW( HANDLE hConsoleOutput, LPWSTR buffer, D
...
@@ -871,9 +879,7 @@ BOOL WINAPI ReadConsoleOutputCharacterW( HANDLE hConsoleOutput, LPWSTR buffer, D
req
->
wrap
=
TRUE
;
req
->
wrap
=
TRUE
;
wine_server_set_reply
(
req
,
buffer
,
count
*
sizeof
(
WCHAR
)
);
wine_server_set_reply
(
req
,
buffer
,
count
*
sizeof
(
WCHAR
)
);
if
((
ret
=
!
wine_server_call_err
(
req
)))
if
((
ret
=
!
wine_server_call_err
(
req
)))
{
*
read_count
=
wine_server_reply_size
(
reply
)
/
sizeof
(
WCHAR
);
if
(
read_count
)
*
read_count
=
wine_server_reply_size
(
reply
)
/
sizeof
(
WCHAR
);
}
}
}
SERVER_END_REQ
;
SERVER_END_REQ
;
return
ret
;
return
ret
;
...
...
dlls/kernel32/tests/console.c
View file @
c905b7e7
...
@@ -1855,6 +1855,90 @@ static void test_FillConsoleOutputAttribute(HANDLE output_handle)
...
@@ -1855,6 +1855,90 @@ static void test_FillConsoleOutputAttribute(HANDLE output_handle)
ok
(
count
==
1
,
"Expected count to be 1, got %u
\n
"
,
count
);
ok
(
count
==
1
,
"Expected count to be 1, got %u
\n
"
,
count
);
}
}
static
void
test_ReadConsoleOutputCharacterW
(
HANDLE
output_handle
)
{
WCHAR
read
;
COORD
origin
=
{
0
,
0
};
DWORD
count
;
BOOL
ret
;
int
i
;
const
struct
{
HANDLE
hConsoleOutput
;
LPWSTR
buffer
;
DWORD
length
;
COORD
coord
;
LPDWORD
read_count
;
DWORD
expected_count
;
DWORD
last_error
;
int
win7_crash
;
}
invalid_table
[]
=
{
{
NULL
,
NULL
,
0
,
origin
,
NULL
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
,
1
},
{
NULL
,
NULL
,
0
,
origin
,
&
count
,
0
,
ERROR_INVALID_HANDLE
},
{
NULL
,
NULL
,
1
,
origin
,
NULL
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
,
1
},
{
NULL
,
NULL
,
1
,
origin
,
&
count
,
0
,
ERROR_INVALID_HANDLE
,
1
},
{
NULL
,
&
read
,
0
,
origin
,
NULL
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
,
1
},
{
NULL
,
&
read
,
0
,
origin
,
&
count
,
0
,
ERROR_INVALID_HANDLE
},
{
NULL
,
&
read
,
1
,
origin
,
NULL
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
,
1
},
{
NULL
,
&
read
,
1
,
origin
,
&
count
,
0
,
ERROR_INVALID_HANDLE
},
{
INVALID_HANDLE_VALUE
,
NULL
,
0
,
origin
,
NULL
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
,
1
},
{
INVALID_HANDLE_VALUE
,
NULL
,
0
,
origin
,
&
count
,
0
,
ERROR_INVALID_HANDLE
},
{
INVALID_HANDLE_VALUE
,
NULL
,
1
,
origin
,
NULL
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
,
1
},
{
INVALID_HANDLE_VALUE
,
NULL
,
1
,
origin
,
&
count
,
0
,
ERROR_INVALID_HANDLE
,
1
},
{
INVALID_HANDLE_VALUE
,
&
read
,
0
,
origin
,
NULL
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
,
1
},
{
INVALID_HANDLE_VALUE
,
&
read
,
0
,
origin
,
&
count
,
0
,
ERROR_INVALID_HANDLE
},
{
INVALID_HANDLE_VALUE
,
&
read
,
1
,
origin
,
NULL
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
,
1
},
{
INVALID_HANDLE_VALUE
,
&
read
,
1
,
origin
,
&
count
,
0
,
ERROR_INVALID_HANDLE
},
{
output_handle
,
NULL
,
0
,
origin
,
NULL
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
,
1
},
{
output_handle
,
NULL
,
1
,
origin
,
NULL
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
,
1
},
{
output_handle
,
NULL
,
1
,
origin
,
&
count
,
1
,
ERROR_INVALID_ACCESS
,
1
},
{
output_handle
,
NULL
,
10
,
origin
,
&
count
,
10
,
ERROR_INVALID_ACCESS
,
1
},
{
output_handle
,
&
read
,
0
,
origin
,
NULL
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
,
1
},
{
output_handle
,
&
read
,
1
,
origin
,
NULL
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
,
1
},
};
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
].
read_count
)
count
=
0xdeadbeef
;
ret
=
ReadConsoleOutputCharacterW
(
invalid_table
[
i
].
hConsoleOutput
,
invalid_table
[
i
].
buffer
,
invalid_table
[
i
].
length
,
invalid_table
[
i
].
coord
,
invalid_table
[
i
].
read_count
);
ok
(
!
ret
,
"[%d] Expected ReadConsoleOutputCharacterW to return FALSE, got %d
\n
"
,
i
,
ret
);
if
(
invalid_table
[
i
].
read_count
)
{
ok
(
count
==
invalid_table
[
i
].
expected_count
,
"[%d] Expected 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
=
ReadConsoleOutputCharacterW
(
output_handle
,
NULL
,
0
,
origin
,
&
count
);
ok
(
ret
==
TRUE
,
"Expected ReadConsoleOutputCharacterW to return TRUE, got %d
\n
"
,
ret
);
ok
(
count
==
0
,
"Expected count to be 0, got %u
\n
"
,
count
);
count
=
0xdeadbeef
;
ret
=
ReadConsoleOutputCharacterW
(
output_handle
,
&
read
,
0
,
origin
,
&
count
);
ok
(
ret
==
TRUE
,
"Expected ReadConsoleOutputCharacterW to return TRUE, got %d
\n
"
,
ret
);
ok
(
count
==
0
,
"Expected count to be 0, got %u
\n
"
,
count
);
count
=
0xdeadbeef
;
ret
=
ReadConsoleOutputCharacterW
(
output_handle
,
&
read
,
1
,
origin
,
&
count
);
ok
(
ret
==
TRUE
,
"Expected ReadConsoleOutputCharacterW to return TRUE, got %d
\n
"
,
ret
);
ok
(
count
==
1
,
"Expected count to be 1, got %u
\n
"
,
count
);
}
START_TEST
(
console
)
START_TEST
(
console
)
{
{
static
const
char
font_name
[]
=
"Lucida Console"
;
static
const
char
font_name
[]
=
"Lucida Console"
;
...
@@ -1969,4 +2053,5 @@ START_TEST(console)
...
@@ -1969,4 +2053,5 @@ START_TEST(console)
test_FillConsoleOutputCharacterA
(
hConOut
);
test_FillConsoleOutputCharacterA
(
hConOut
);
test_FillConsoleOutputCharacterW
(
hConOut
);
test_FillConsoleOutputCharacterW
(
hConOut
);
test_FillConsoleOutputAttribute
(
hConOut
);
test_FillConsoleOutputAttribute
(
hConOut
);
test_ReadConsoleOutputCharacterW
(
hConOut
);
}
}
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