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
e03a3fe5
Commit
e03a3fe5
authored
Apr 16, 2014
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
Apr 16, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Add a workaround for broken apps that pass negative values to ReadConsole.
parent
b2d85738
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
10 deletions
+12
-10
console.c
dlls/kernel32/console.c
+10
-2
console.c
dlls/kernel32/tests/console.c
+2
-8
No files found.
dlls/kernel32/console.c
View file @
e03a3fe5
...
...
@@ -34,6 +34,7 @@
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
...
...
@@ -1614,9 +1615,10 @@ BOOL WINAPI ReadConsoleA(HANDLE hConsoleInput, LPVOID lpBuffer, DWORD nNumberOfC
}
if
((
ret
=
ReadConsoleW
(
hConsoleInput
,
ptr
,
nNumberOfCharsToRead
,
&
ncr
,
NULL
)))
{
ncr
=
WideCharToMultiByte
(
GetConsoleCP
(),
0
,
ptr
,
ncr
,
lpBuffer
,
nNumberOfCharsToRead
,
NULL
,
NULL
);
if
(
lpNumberOfCharsRead
)
*
lpNumberOfCharsRead
=
ncr
;
if
(
lpNumberOfCharsRead
)
*
lpNumberOfCharsRead
=
ncr
;
}
HeapFree
(
GetProcessHeap
(),
0
,
ptr
);
return
ret
;
...
...
@@ -1637,6 +1639,12 @@ BOOL WINAPI ReadConsoleW(HANDLE hConsoleInput, LPVOID lpBuffer,
TRACE
(
"(%p,%p,%d,%p,%p)
\n
"
,
hConsoleInput
,
lpBuffer
,
nNumberOfCharsToRead
,
lpNumberOfCharsRead
,
lpReserved
);
if
(
nNumberOfCharsToRead
>
INT_MAX
)
{
SetLastError
(
ERROR_NOT_ENOUGH_MEMORY
);
return
FALSE
;
}
if
(
!
GetConsoleMode
(
hConsoleInput
,
&
mode
))
return
FALSE
;
if
((
fd
=
get_console_bare_fd
(
hConsoleInput
))
!=
-
1
)
...
...
dlls/kernel32/tests/console.c
View file @
e03a3fe5
...
...
@@ -2566,8 +2566,6 @@ static void test_ReadConsole(void)
ok
(
ret
==
INVALID_FILE_SIZE
,
"expected INVALID_FILE_SIZE, got %#x
\n
"
,
ret
);
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"expected ERROR_INVALID_HANDLE, got %d
\n
"
,
GetLastError
());
if
(
0
)
/* FIXME: uncomment once Wine doesn't hang forever */
{
bytes
=
0xdeadbeef
;
SetLastError
(
0xdeadbeef
);
ret
=
ReadFile
(
std_input
,
buf
,
-
128
,
&
bytes
,
NULL
);
...
...
@@ -2580,18 +2578,14 @@ if (0) /* FIXME: uncomment once Wine doesn't hang forever */
ret
=
ReadConsoleA
(
std_input
,
buf
,
-
128
,
&
bytes
,
NULL
);
ok
(
!
ret
,
"expected 0, got %u
\n
"
,
ret
);
ok
(
GetLastError
()
==
ERROR_NOT_ENOUGH_MEMORY
,
"expected ERROR_NOT_ENOUGH_MEMORY, got %d
\n
"
,
GetLastError
());
ok
(
bytes
==
0xdeadbeef
,
"expected 0xdeadbeef, %#x
\n
"
,
bytes
);
}
ok
(
bytes
==
0xdeadbeef
,
"expected 0xdeadbeef, got %#x
\n
"
,
bytes
);
if
(
0
)
/* FIXME: uncomment once Wine doesn't hang forever */
{
bytes
=
0xdeadbeef
;
SetLastError
(
0xdeadbeef
);
ret
=
ReadConsoleW
(
std_input
,
buf
,
-
128
,
&
bytes
,
NULL
);
ok
(
!
ret
,
"expected 0, got %u
\n
"
,
ret
);
ok
(
GetLastError
()
==
ERROR_NOT_ENOUGH_MEMORY
,
"expected ERROR_NOT_ENOUGH_MEMORY, got %d
\n
"
,
GetLastError
());
ok
(
bytes
==
0xdeadbeef
,
"expected 0xdeadbeef, %#x
\n
"
,
bytes
);
}
ok
(
bytes
==
0xdeadbeef
,
"expected 0xdeadbeef, got %#x
\n
"
,
bytes
);
}
START_TEST
(
console
)
...
...
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