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
a0d8d1e2
Commit
a0d8d1e2
authored
Aug 02, 2013
by
Daniel Lehman
Committed by
Alexandre Julliard
Aug 16, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Invoke invalid_handler in _wcscpy_s.
parent
637257b9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
10 deletions
+25
-10
string.c
dlls/msvcrt/tests/string.c
+21
-1
wcs.c
dlls/msvcrt/wcs.c
+4
-9
No files found.
dlls/msvcrt/tests/string.c
View file @
a0d8d1e2
...
...
@@ -808,23 +808,33 @@ static void test_wcscpy_s(void)
return
;
}
if
(
p_set_invalid_parameter_handler
)
ok
(
p_set_invalid_parameter_handler
(
test_invalid_parameter_handler
)
==
NULL
,
"Invalid parameter handler was already set
\n
"
);
/* Test NULL Dest */
errno
=
EBADF
;
ret
=
p_wcscpy_s
(
NULL
,
18
,
szLongText
);
ok
(
ret
==
EINVAL
,
"p_wcscpy_s expect EINVAL got %d
\n
"
,
ret
);
ok
(
errno
==
EINVAL
,
"expected errno EINVAL got %d
\n
"
,
errno
);
/* Test NULL Source */
errno
=
EBADF
;
szDest
[
0
]
=
'A'
;
ret
=
p_wcscpy_s
(
szDest
,
18
,
NULL
);
ok
(
ret
==
EINVAL
,
"expected EINVAL got %d
\n
"
,
ret
);
ok
(
szDest
[
0
]
==
0
,
"szDest[0] not 0
\n
"
);
ok
(
errno
==
EINVAL
,
"expected errno EINVAL got %d
\n
"
,
errno
);
ok
(
szDest
[
0
]
==
0
,
"szDest[0] not 0, got %c
\n
"
,
szDest
[
0
]);
/* Test invalid size */
errno
=
EBADF
;
szDest
[
0
]
=
'A'
;
ret
=
p_wcscpy_s
(
szDest
,
0
,
szLongText
);
/* Later versions changed the return value for this case to EINVAL,
* and don't modify the result if the dest size is 0.
*/
ok
(
ret
==
ERANGE
||
ret
==
EINVAL
,
"expected ERANGE/EINVAL got %d
\n
"
,
ret
);
ok
(
errno
==
ERANGE
||
errno
==
EINVAL
,
"expected errno ERANGE/EINVAL got %d
\n
"
,
errno
);
ok
(
szDest
[
0
]
==
0
||
ret
==
EINVAL
,
"szDest[0] not 0
\n
"
);
/* Copy same buffer size */
...
...
@@ -833,14 +843,20 @@ static void test_wcscpy_s(void)
ok
(
lstrcmpW
(
szDest
,
szLongText
)
==
0
,
"szDest != szLongText
\n
"
);
/* Copy smaller buffer size */
errno
=
EBADF
;
szDest
[
0
]
=
'A'
;
ret
=
p_wcscpy_s
(
szDestShort
,
8
,
szLongText
);
ok
(
ret
==
ERANGE
||
ret
==
EINVAL
,
"expected ERANGE/EINVAL got %d
\n
"
,
ret
);
ok
(
errno
==
ERANGE
||
errno
==
EINVAL
,
"expected errno ERANGE/EINVAL got %d
\n
"
,
errno
);
ok
(
szDestShort
[
0
]
==
0
,
"szDestShort[0] not 0
\n
"
);
if
(
!
p_wcsncpy_s
)
{
win_skip
(
"wcsncpy_s not found
\n
"
);
if
(
p_set_invalid_parameter_handler
)
ok
(
p_set_invalid_parameter_handler
(
NULL
)
==
test_invalid_parameter_handler
,
"Cannot reset invalid parameter handler
\n
"
);
return
;
}
...
...
@@ -886,6 +902,10 @@ static void test_wcscpy_s(void)
ok
(
ret
==
STRUNCATE
,
"expected ERROR_SUCCESS got %d
\n
"
,
ret
);
ok
(
szDestShort
[
0
]
==
'1'
&&
szDestShort
[
1
]
==
'1'
&&
szDestShort
[
2
]
==
'1'
&&
szDestShort
[
3
]
==
'1'
,
"szDestShort = %s
\n
"
,
wine_dbgstr_w
(
szDestShort
));
if
(
p_set_invalid_parameter_handler
)
ok
(
p_set_invalid_parameter_handler
(
NULL
)
==
test_invalid_parameter_handler
,
"Cannot reset invalid parameter handler
\n
"
);
}
static
void
test__wcsupr_s
(
void
)
...
...
dlls/msvcrt/wcs.c
View file @
a0d8d1e2
...
...
@@ -1391,22 +1391,17 @@ INT CDECL MSVCRT_wcscpy_s( MSVCRT_wchar_t* wcDest, MSVCRT_size_t numElement, con
{
MSVCRT_size_t
size
=
0
;
if
(
!
wcDest
||
!
numElement
)
return
MSVCRT_EINVAL
;
if
(
!
MSVCRT_CHECK_PMT
(
wcDest
))
return
MSVCRT_EINVAL
;
if
(
!
MSVCRT_CHECK_PMT
(
numElement
))
return
MSVCRT_EINVAL
;
wcDest
[
0
]
=
0
;
if
(
!
wcSrc
)
{
return
MSVCRT_EINVAL
;
}
if
(
!
MSVCRT_CHECK_PMT
(
wcSrc
))
return
MSVCRT_EINVAL
;
size
=
strlenW
(
wcSrc
)
+
1
;
if
(
size
>
numElement
)
{
if
(
!
MSVCRT_CHECK_PMT_ERR
(
size
<=
numElement
,
MSVCRT_ERANGE
))
return
MSVCRT_ERANGE
;
}
memcpy
(
wcDest
,
wcSrc
,
size
*
sizeof
(
WCHAR
)
);
...
...
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