Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
2281c29b
Commit
2281c29b
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 WriteConsoleOutputCharacterW.
parent
9febdf3f
Hide 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 @
2281c29b
...
...
@@ -1729,6 +1729,14 @@ BOOL WINAPI WriteConsoleOutputCharacterW( HANDLE hConsoleOutput, LPCWSTR str, DW
TRACE
(
"(%p,%s,%d,%dx%d,%p)
\n
"
,
hConsoleOutput
,
debugstr_wn
(
str
,
length
),
length
,
coord
.
X
,
coord
.
Y
,
lpNumCharsWritten
);
if
((
length
>
0
&&
!
str
)
||
!
lpNumCharsWritten
)
{
SetLastError
(
ERROR_INVALID_ACCESS
);
return
FALSE
;
}
*
lpNumCharsWritten
=
0
;
SERVER_START_REQ
(
write_console_output
)
{
req
->
handle
=
console_handle_unmap
(
hConsoleOutput
);
...
...
@@ -1738,9 +1746,7 @@ BOOL WINAPI WriteConsoleOutputCharacterW( HANDLE hConsoleOutput, LPCWSTR str, DW
req
->
wrap
=
TRUE
;
wine_server_add_data
(
req
,
str
,
length
*
sizeof
(
WCHAR
)
);
if
((
ret
=
!
wine_server_call_err
(
req
)))
{
if
(
lpNumCharsWritten
)
*
lpNumCharsWritten
=
reply
->
written
;
}
*
lpNumCharsWritten
=
reply
->
written
;
}
SERVER_END_REQ
;
return
ret
;
...
...
dlls/kernel32/tests/console.c
View file @
2281c29b
...
...
@@ -1401,6 +1401,90 @@ static void test_WriteConsoleInputW(HANDLE input_handle)
ok
(
count
==
1
,
"Expected count to be 1, got %u
\n
"
,
count
);
}
static
void
test_WriteConsoleOutputCharacterW
(
HANDLE
output_handle
)
{
static
const
WCHAR
outputW
[]
=
{
'a'
,
0
};
COORD
origin
=
{
0
,
0
};
DWORD
count
;
BOOL
ret
;
int
i
;
const
struct
{
HANDLE
hConsoleOutput
;
LPCWSTR
str
;
DWORD
length
;
COORD
coord
;
LPDWORD
lpNumCharsWritten
;
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
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
,
1
},
{
NULL
,
outputW
,
0
,
origin
,
NULL
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
,
1
},
{
NULL
,
outputW
,
0
,
origin
,
&
count
,
0
,
ERROR_INVALID_HANDLE
},
{
NULL
,
outputW
,
1
,
origin
,
NULL
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
,
1
},
{
NULL
,
outputW
,
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
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
,
1
},
{
INVALID_HANDLE_VALUE
,
outputW
,
0
,
origin
,
NULL
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
,
1
},
{
INVALID_HANDLE_VALUE
,
outputW
,
0
,
origin
,
&
count
,
0
,
ERROR_INVALID_HANDLE
},
{
INVALID_HANDLE_VALUE
,
outputW
,
1
,
origin
,
NULL
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
,
1
},
{
INVALID_HANDLE_VALUE
,
outputW
,
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
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
,
1
},
{
output_handle
,
outputW
,
0
,
origin
,
NULL
,
0xdeadbeef
,
ERROR_INVALID_ACCESS
,
1
},
{
output_handle
,
outputW
,
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
].
lpNumCharsWritten
)
count
=
0xdeadbeef
;
ret
=
WriteConsoleOutputCharacterW
(
invalid_table
[
i
].
hConsoleOutput
,
invalid_table
[
i
].
str
,
invalid_table
[
i
].
length
,
invalid_table
[
i
].
coord
,
invalid_table
[
i
].
lpNumCharsWritten
);
ok
(
!
ret
,
"[%d] Expected WriteConsoleOutputCharacterW to return FALSE, got %d
\n
"
,
i
,
ret
);
if
(
invalid_table
[
i
].
lpNumCharsWritten
)
{
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
=
WriteConsoleOutputCharacterW
(
output_handle
,
NULL
,
0
,
origin
,
&
count
);
ok
(
ret
==
TRUE
,
"Expected WriteConsoleOutputCharacterW to return TRUE, got %d
\n
"
,
ret
);
ok
(
count
==
0
,
"Expected count to be 0, got %u
\n
"
,
count
);
count
=
0xdeadbeef
;
ret
=
WriteConsoleOutputCharacterW
(
output_handle
,
outputW
,
0
,
origin
,
&
count
);
ok
(
ret
==
TRUE
,
"Expected WriteConsoleOutputCharacterW to return TRUE, got %d
\n
"
,
ret
);
ok
(
count
==
0
,
"Expected count to be 0, got %u
\n
"
,
count
);
count
=
0xdeadbeef
;
ret
=
WriteConsoleOutputCharacterW
(
output_handle
,
outputW
,
1
,
origin
,
&
count
);
ok
(
ret
==
TRUE
,
"Expected WriteConsoleOutputCharacterW 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
;
...
...
@@ -1457,4 +1541,5 @@ START_TEST(console)
test_GetNumberOfConsoleInputEvents
(
hConIn
);
test_WriteConsoleInputA
(
hConIn
);
test_WriteConsoleInputW
(
hConIn
);
test_WriteConsoleOutputCharacterW
(
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