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
0b95ebd2
Commit
0b95ebd2
authored
Mar 27, 2017
by
Alex Henrie
Committed by
Alexandre Julliard
Mar 28, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Check for invalid flags in codepage conversion functions.
Signed-off-by:
Alex Henrie
<
alexhenrie24@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
be6008d2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
0 deletions
+62
-0
locale.c
dlls/kernel32/locale.c
+23
-0
codepage.c
dlls/kernel32/tests/codepage.c
+39
-0
No files found.
dlls/kernel32/locale.c
View file @
0b95ebd2
...
...
@@ -54,6 +54,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(nls);
#define LOCALE_LOCALEINFOFLAGSMASK (LOCALE_NOUSEROVERRIDE|LOCALE_USE_CP_ACP|\
LOCALE_RETURN_NUMBER|LOCALE_RETURN_GENITIVE_NAMES)
#define MB_FLAGSMASK (MB_PRECOMPOSED|MB_COMPOSITE|MB_USEGLYPHCHARS|MB_ERR_INVALID_CHARS)
#define WC_FLAGSMASK (WC_DISCARDNS|WC_SEPCHARS|WC_DEFAULTCHAR|WC_ERR_INVALID_CHARS|\
WC_COMPOSITECHECK|WC_NO_BEST_FIT_CHARS)
/* current code pages */
static
const
union
cptable
*
ansi_cptable
;
...
...
@@ -2422,6 +2425,11 @@ INT WINAPI MultiByteToWideChar( UINT page, DWORD flags, LPCSTR src, INT srclen,
#endif
/* fall through */
case
CP_UTF8
:
if
(
flags
&
~
MB_FLAGSMASK
)
{
SetLastError
(
ERROR_INVALID_FLAGS
);
return
0
;
}
ret
=
wine_utf8_mbstowcs
(
flags
,
src
,
srclen
,
dst
,
dstlen
);
break
;
default:
...
...
@@ -2430,6 +2438,11 @@ INT WINAPI MultiByteToWideChar( UINT page, DWORD flags, LPCSTR src, INT srclen,
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
0
;
}
if
(
flags
&
~
MB_FLAGSMASK
)
{
SetLastError
(
ERROR_INVALID_FLAGS
);
return
0
;
}
ret
=
wine_cp_mbstowcs
(
table
,
flags
,
src
,
srclen
,
dst
,
dstlen
);
break
;
}
...
...
@@ -2653,6 +2666,11 @@ INT WINAPI WideCharToMultiByte( UINT page, DWORD flags, LPCWSTR src, INT srclen,
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
0
;
}
if
(
flags
&
~
WC_FLAGSMASK
)
{
SetLastError
(
ERROR_INVALID_FLAGS
);
return
0
;
}
ret
=
wine_utf8_wcstombs
(
flags
,
src
,
srclen
,
dst
,
dstlen
);
break
;
default:
...
...
@@ -2661,6 +2679,11 @@ INT WINAPI WideCharToMultiByte( UINT page, DWORD flags, LPCWSTR src, INT srclen,
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
0
;
}
if
(
flags
&
~
WC_FLAGSMASK
)
{
SetLastError
(
ERROR_INVALID_FLAGS
);
return
0
;
}
ret
=
wine_cp_wcstombs
(
table
,
flags
,
src
,
srclen
,
dst
,
dstlen
,
defchar
,
used
?
&
used_tmp
:
NULL
);
if
(
used
)
*
used
=
used_tmp
;
...
...
dlls/kernel32/tests/codepage.c
View file @
0b95ebd2
...
...
@@ -209,6 +209,40 @@ static void test_other_invalid_parameters(void)
BOOL
used
;
INT
len
;
/* Unrecognized flag => ERROR_INVALID_FLAGS */
SetLastError
(
0xdeadbeef
);
len
=
WideCharToMultiByte
(
CP_ACP
,
0x100
,
w_string
,
-
1
,
c_string
,
c_string_len
,
NULL
,
NULL
);
ok
(
len
==
0
&&
GetLastError
()
==
ERROR_INVALID_FLAGS
,
"len=%d error=%x
\n
"
,
len
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
len
=
WideCharToMultiByte
(
CP_ACP
,
0x800
,
w_string
,
-
1
,
c_string
,
c_string_len
,
NULL
,
NULL
);
ok
(
len
==
0
&&
GetLastError
()
==
ERROR_INVALID_FLAGS
,
"len=%d error=%x
\n
"
,
len
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
len
=
MultiByteToWideChar
(
CP_ACP
,
0x10
,
c_string
,
-
1
,
w_string
,
w_string_len
);
ok
(
len
==
0
&&
GetLastError
()
==
ERROR_INVALID_FLAGS
,
"len=%d error=%x
\n
"
,
len
,
GetLastError
());
/* Unrecognized flag and invalid codepage => ERROR_INVALID_PARAMETER */
SetLastError
(
0xdeadbeef
);
len
=
WideCharToMultiByte
(
0xdeadbeef
,
0x100
,
w_string
,
w_string_len
,
c_string
,
c_string_len
,
NULL
,
NULL
);
ok
(
len
==
0
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"len=%d error=%x
\n
"
,
len
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
len
=
MultiByteToWideChar
(
0xdeadbeef
,
0x10
,
c_string
,
c_string_len
,
w_string
,
w_string_len
);
ok
(
len
==
0
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"len=%d error=%x
\n
"
,
len
,
GetLastError
());
/* Unrecognized flag and src is NULL => ERROR_INVALID_PARAMETER */
SetLastError
(
0xdeadbeef
);
len
=
WideCharToMultiByte
(
CP_ACP
,
0x100
,
NULL
,
-
1
,
c_string
,
c_string_len
,
NULL
,
NULL
);
ok
(
len
==
0
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"len=%d error=%x
\n
"
,
len
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
len
=
MultiByteToWideChar
(
CP_ACP
,
0x10
,
NULL
,
-
1
,
w_string
,
w_string_len
);
ok
(
len
==
0
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"len=%d error=%x
\n
"
,
len
,
GetLastError
());
/* srclen=0 => ERROR_INVALID_PARAMETER */
SetLastError
(
0xdeadbeef
);
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
w_string
,
0
,
c_string
,
c_string_len
,
NULL
,
NULL
);
...
...
@@ -266,6 +300,11 @@ static void test_other_invalid_parameters(void)
SetLastError
(
0xdeadbeef
);
len
=
WideCharToMultiByte
(
CP_UTF7
,
1
,
w_string
,
w_string_len
,
c_string
,
c_string_len
,
NULL
,
&
used
);
ok
(
len
==
0
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"len=%d error=%x
\n
"
,
len
,
GetLastError
());
/* CP_UTF8, unrecognized flag and used not NULL => ERROR_INVALID_PARAMETER */
SetLastError
(
0xdeadbeef
);
len
=
WideCharToMultiByte
(
CP_UTF8
,
0x100
,
w_string
,
w_string_len
,
c_string
,
c_string_len
,
NULL
,
&
used
);
ok
(
len
==
0
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"len=%d error=%x
\n
"
,
len
,
GetLastError
());
}
static
void
test_overlapped_buffers
(
void
)
...
...
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