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
8df606fe
Commit
8df606fe
authored
Oct 04, 2011
by
Piotr Caban
Committed by
Alexandre Julliard
Oct 04, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Fix wcsncpy_s implementation.
parent
50110d4b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
2 deletions
+37
-2
string.c
dlls/msvcrt/tests/string.c
+36
-1
wcs.c
dlls/msvcrt/wcs.c
+1
-1
No files found.
dlls/msvcrt/tests/string.c
View file @
8df606fe
...
...
@@ -61,6 +61,7 @@ static int (__cdecl *pstrcat_s)(char *dst, size_t len, const char *src);
static
int
(
__cdecl
*
p_mbsnbcat_s
)(
unsigned
char
*
dst
,
size_t
size
,
const
unsigned
char
*
src
,
size_t
count
);
static
int
(
__cdecl
*
p_mbsnbcpy_s
)(
unsigned
char
*
dst
,
size_t
size
,
const
unsigned
char
*
src
,
size_t
count
);
static
int
(
__cdecl
*
p_wcscpy_s
)(
wchar_t
*
wcDest
,
size_t
size
,
const
wchar_t
*
wcSrc
);
static
int
(
__cdecl
*
p_wcsncpy_s
)(
wchar_t
*
wcDest
,
size_t
size
,
const
wchar_t
*
wcSrc
,
size_t
count
);
static
int
(
__cdecl
*
p_wcsncat_s
)(
wchar_t
*
dst
,
size_t
elem
,
const
wchar_t
*
src
,
size_t
count
);
static
int
(
__cdecl
*
p_wcsupr_s
)(
wchar_t
*
str
,
size_t
size
);
static
size_t
(
__cdecl
*
p_strnlen
)(
const
char
*
,
size_t
);
...
...
@@ -615,7 +616,7 @@ static void test_wcscpy_s(void)
if
(
!
p_wcscpy_s
)
{
skip
(
"wcscpy_s not found
\n
"
);
win_
skip
(
"wcscpy_s not found
\n
"
);
return
;
}
...
...
@@ -648,6 +649,39 @@ static void test_wcscpy_s(void)
ret
=
p_wcscpy_s
(
szDestShort
,
8
,
szLongText
);
ok
(
ret
==
ERANGE
||
ret
==
EINVAL
,
"expected ERANGE/EINVAL got %d
\n
"
,
ret
);
ok
(
szDestShort
[
0
]
==
0
,
"szDestShort[0] not 0
\n
"
);
if
(
!
p_wcsncpy_s
)
{
win_skip
(
"wcsncpy_s not found
\n
"
);
return
;
}
ret
=
p_wcsncpy_s
(
NULL
,
18
,
szLongText
,
sizeof
(
szLongText
)
/
sizeof
(
WCHAR
));
ok
(
ret
==
EINVAL
,
"p_wcsncpy_s expect EINVAL got %d
\n
"
,
ret
);
szDest
[
0
]
=
'A'
;
ret
=
p_wcsncpy_s
(
szDest
,
18
,
NULL
,
1
);
ok
(
ret
==
EINVAL
,
"expected EINVAL got %d
\n
"
,
ret
);
ok
(
szDest
[
0
]
==
0
,
"szDest[0] not 0
\n
"
);
szDest
[
0
]
=
'A'
;
ret
=
p_wcsncpy_s
(
szDest
,
18
,
NULL
,
0
);
ok
(
ret
==
0
,
"expected ERROR_SUCCESS got %d
\n
"
,
ret
);
ok
(
szDest
[
0
]
==
0
,
"szDest[0] not 0
\n
"
);
szDest
[
0
]
=
'A'
;
ret
=
p_wcsncpy_s
(
szDest
,
0
,
szLongText
,
sizeof
(
szLongText
)
/
sizeof
(
WCHAR
));
ok
(
ret
==
ERANGE
||
ret
==
EINVAL
,
"expected ERANGE/EINVAL got %d
\n
"
,
ret
);
ok
(
szDest
[
0
]
==
0
||
ret
==
EINVAL
,
"szDest[0] not 0
\n
"
);
ret
=
p_wcsncpy_s
(
szDest
,
18
,
szLongText
,
sizeof
(
szLongText
)
/
sizeof
(
WCHAR
));
ok
(
ret
==
0
,
"expected 0 got %d
\n
"
,
ret
);
ok
(
lstrcmpW
(
szDest
,
szLongText
)
==
0
,
"szDest != szLongText
\n
"
);
szDest
[
0
]
=
'A'
;
ret
=
p_wcsncpy_s
(
szDestShort
,
8
,
szLongText
,
sizeof
(
szLongText
)
/
sizeof
(
WCHAR
));
ok
(
ret
==
ERANGE
||
ret
==
EINVAL
,
"expected ERANGE/EINVAL got %d
\n
"
,
ret
);
ok
(
szDestShort
[
0
]
==
0
,
"szDestShort[0] not 0
\n
"
);
}
static
void
test__wcsupr_s
(
void
)
...
...
@@ -2027,6 +2061,7 @@ START_TEST(string)
p_mbsnbcat_s
=
(
void
*
)
GetProcAddress
(
hMsvcrt
,
"_mbsnbcat_s"
);
p_mbsnbcpy_s
=
(
void
*
)
GetProcAddress
(
hMsvcrt
,
"_mbsnbcpy_s"
);
p_wcscpy_s
=
(
void
*
)
GetProcAddress
(
hMsvcrt
,
"wcscpy_s"
);
p_wcsncpy_s
=
(
void
*
)
GetProcAddress
(
hMsvcrt
,
"wcsncpy_s"
);
p_wcsncat_s
=
(
void
*
)
GetProcAddress
(
hMsvcrt
,
"wcsncat_s"
);
p_wcsupr_s
=
(
void
*
)
GetProcAddress
(
hMsvcrt
,
"_wcsupr_s"
);
p_strnlen
=
(
void
*
)
GetProcAddress
(
hMsvcrt
,
"strnlen"
);
...
...
dlls/msvcrt/wcs.c
View file @
8df606fe
...
...
@@ -1210,7 +1210,7 @@ INT CDECL MSVCRT_wcsncpy_s( MSVCRT_wchar_t* wcDest, MSVCRT_size_t numElement, co
if
(
!
wcSrc
)
{
return
MSVCRT_EINVAL
;
return
count
?
MSVCRT_EINVAL
:
0
;
}
size
=
min
(
strlenW
(
wcSrc
),
count
);
...
...
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