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
6e841fdb
Commit
6e841fdb
authored
Dec 23, 2015
by
Alex Henrie
Committed by
Alexandre Julliard
Jan 25, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Set error if dstlen < 0 in codepage conversion functions.
Signed-off-by:
Alex Henrie
<
alexhenrie24@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
92205565
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
21 deletions
+31
-21
locale.c
dlls/kernel32/locale.c
+2
-2
codepage.c
dlls/kernel32/tests/codepage.c
+29
-19
No files found.
dlls/kernel32/locale.c
View file @
6e841fdb
...
...
@@ -2152,7 +2152,7 @@ INT WINAPI MultiByteToWideChar( UINT page, DWORD flags, LPCSTR src, INT srclen,
const
union
cptable
*
table
;
int
ret
;
if
(
!
src
||
!
srclen
||
(
!
dst
&&
dstlen
))
if
(
!
src
||
!
srclen
||
(
!
dst
&&
dstlen
)
||
dstlen
<
0
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
0
;
...
...
@@ -2368,7 +2368,7 @@ INT WINAPI WideCharToMultiByte( UINT page, DWORD flags, LPCWSTR src, INT srclen,
const
union
cptable
*
table
;
int
ret
,
used_tmp
;
if
(
!
src
||
!
srclen
||
(
!
dst
&&
dstlen
))
if
(
!
src
||
!
srclen
||
(
!
dst
&&
dstlen
)
||
dstlen
<
0
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
0
;
...
...
dlls/kernel32/tests/codepage.c
View file @
6e841fdb
...
...
@@ -28,6 +28,7 @@
#include "winbase.h"
#include "winnls.h"
static
const
char
foobarA
[]
=
"foobar"
;
static
const
WCHAR
foobarW
[]
=
{
'f'
,
'o'
,
'o'
,
'b'
,
'a'
,
'r'
,
0
};
static
void
test_destination_buffer
(
void
)
...
...
@@ -144,48 +145,57 @@ static void test_negative_source_length(void)
static
void
test_negative_dest_length
(
void
)
{
int
len
,
i
;
static
char
buf
[
LONGBUFLEN
];
static
WCHAR
bufW
[
LONGBUFLEN
];
static
char
bufA
[
LONGBUFLEN
];
static
WCHAR
originalW
[
LONGBUFLEN
];
static
char
originalA
[
LONGBUFLEN
];
DWORD
theError
;
/* Test return on -1 dest length */
SetLastError
(
0xdeadbeef
);
memset
(
buf
,
'x'
,
sizeof
(
buf
));
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
foobarW
,
-
1
,
buf
,
-
1
,
NULL
,
NULL
);
todo_wine
{
ok
(
len
==
0
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"WideCharToMultiByte(destlen -1): len=%d error=%x
\n
"
,
len
,
GetLastError
());
}
memset
(
bufA
,
'x'
,
sizeof
(
bufA
));
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
foobarW
,
-
1
,
bufA
,
-
1
,
NULL
,
NULL
);
ok
(
len
==
0
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"WideCharToMultiByte(destlen -1): len=%d error=%x
\n
"
,
len
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
memset
(
bufW
,
'x'
,
sizeof
(
bufW
));
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
foobarA
,
-
1
,
bufW
,
-
1
);
ok
(
len
==
0
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"MultiByteToWideChar(destlen -1): len=%d error=%x
\n
"
,
len
,
GetLastError
());
/* Test return on -1000 dest length */
SetLastError
(
0xdeadbeef
);
memset
(
buf
,
'x'
,
sizeof
(
buf
));
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
foobarW
,
-
1
,
buf
,
-
1000
,
NULL
,
NULL
);
todo_wine
{
ok
(
len
==
0
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"WideCharToMultiByte(destlen -1000): len=%d error=%x
\n
"
,
len
,
GetLastError
());
}
memset
(
bufA
,
'x'
,
sizeof
(
bufA
));
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
foobarW
,
-
1
,
bufA
,
-
1000
,
NULL
,
NULL
);
ok
(
len
==
0
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"WideCharToMultiByte(destlen -1000): len=%d error=%x
\n
"
,
len
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
memset
(
bufW
,
'x'
,
sizeof
(
bufW
));
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
foobarA
,
-
1000
,
bufW
,
-
1
);
ok
(
len
==
0
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"MultiByteToWideChar(destlen -1000): len=%d error=%x
\n
"
,
len
,
GetLastError
());
/* Test return on INT_MAX dest length */
SetLastError
(
0xdeadbeef
);
memset
(
buf
,
'x'
,
sizeof
(
buf
));
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
foobarW
,
-
1
,
buf
,
INT_MAX
,
NULL
,
NULL
);
ok
(
len
==
7
&&
!
lstrcmpA
(
buf
,
"foobar"
)
&&
GetLastError
()
==
0xdeadbeef
,
memset
(
buf
A
,
'x'
,
sizeof
(
bufA
));
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
foobarW
,
-
1
,
buf
A
,
INT_MAX
,
NULL
,
NULL
);
ok
(
len
==
7
&&
!
lstrcmpA
(
buf
A
,
"foobar"
)
&&
GetLastError
()
==
0xdeadbeef
,
"WideCharToMultiByte(destlen INT_MAX): len=%d error=%x
\n
"
,
len
,
GetLastError
());
/* Test return on INT_MAX dest length and very long input */
SetLastError
(
0xdeadbeef
);
memset
(
buf
,
'x'
,
sizeof
(
buf
));
memset
(
buf
A
,
'x'
,
sizeof
(
bufA
));
for
(
i
=
0
;
i
<
LONGBUFLEN
-
1
;
i
++
)
{
originalW
[
i
]
=
'Q'
;
originalA
[
i
]
=
'Q'
;
}
originalW
[
LONGBUFLEN
-
1
]
=
0
;
originalA
[
LONGBUFLEN
-
1
]
=
0
;
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
originalW
,
-
1
,
buf
,
INT_MAX
,
NULL
,
NULL
);
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
originalW
,
-
1
,
buf
A
,
INT_MAX
,
NULL
,
NULL
);
theError
=
GetLastError
();
ok
(
len
==
LONGBUFLEN
&&
!
lstrcmpA
(
buf
,
originalA
)
&&
theError
==
0xdeadbeef
,
ok
(
len
==
LONGBUFLEN
&&
!
lstrcmpA
(
buf
A
,
originalA
)
&&
theError
==
0xdeadbeef
,
"WideCharToMultiByte(srclen %d, destlen INT_MAX): len %d error=%x
\n
"
,
LONGBUFLEN
,
len
,
theError
);
}
...
...
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