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
93b3ba76
Commit
93b3ba76
authored
Mar 18, 2010
by
Nikolay Sivov
Committed by
Alexandre Julliard
Mar 18, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shlwapi: Fix StrCpyNW to deal with null inputs better, and don't use lstrcpynW.
parent
e669ffe6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
9 deletions
+46
-9
string.c
dlls/shlwapi/string.c
+19
-9
string.c
dlls/shlwapi/tests/string.c
+27
-0
No files found.
dlls/shlwapi/string.c
View file @
93b3ba76
...
...
@@ -507,22 +507,32 @@ LPWSTR WINAPI StrCpyW(LPWSTR lpszStr, LPCWSTR lpszSrc)
* Copy a string to another string, up to a maximum number of characters.
*
* PARAMS
*
lpszStr
[O] Destination string
*
lpszSrc
[I] Source string
*
iLen
[I] Maximum number of chars to copy
*
dst
[O] Destination string
*
src
[I] Source string
*
count
[I] Maximum number of chars to copy
*
* RETURNS
*
lpszStr
.
*
dst
.
*/
LPWSTR
WINAPI
StrCpyNW
(
LPWSTR
lpszStr
,
LPCWSTR
lpszSrc
,
int
iLen
)
LPWSTR
WINAPI
StrCpyNW
(
LPWSTR
dst
,
LPCWSTR
src
,
int
count
)
{
TRACE
(
"(%p,%s,%i)
\n
"
,
lpszStr
,
debugstr_w
(
lpszSrc
),
iLen
);
LPWSTR
d
=
dst
;
LPCWSTR
s
=
src
;
lstrcpynW
(
lpszStr
,
lpszSrc
,
iLen
);
return
lpszStr
;
}
TRACE
(
"(%p,%s,%i)
\n
"
,
dst
,
debugstr_w
(
src
),
count
);
if
(
s
)
{
while
((
count
>
1
)
&&
*
s
)
{
count
--
;
*
d
++
=
*
s
++
;
}
}
if
(
count
)
*
d
=
0
;
return
dst
;
}
/*************************************************************************
* SHLWAPI_StrStrHelperA
...
...
dlls/shlwapi/tests/string.c
View file @
93b3ba76
...
...
@@ -863,6 +863,33 @@ static void test_StrXXX_overflows(void)
else
win_skip
(
"StrCatBuffA() is not available
\n
"
);
if
(
0
)
{
/* crashes on XP */
StrCpyNW
(
wbuf
,
(
LPCWSTR
)
0x1
,
10
);
StrCpyNW
((
LPWSTR
)
0x1
,
wstr1
,
10
);
}
memset
(
wbuf
,
0xbf
,
sizeof
(
wbuf
));
expect_eq
(
StrCpyNW
(
wbuf
,
(
LPCWSTR
)
0x1
,
1
),
wbuf
,
PWCHAR
,
"%p"
);
expect_eq
(
wbuf
[
0
],
0
,
WCHAR
,
"%x"
);
expect_eq
(
wbuf
[
1
],
(
WCHAR
)
0xbfbf
,
WCHAR
,
"%x"
);
memset
(
wbuf
,
0xbf
,
sizeof
(
wbuf
));
expect_eq
(
StrCpyNW
(
wbuf
,
0
,
10
),
wbuf
,
PWCHAR
,
"%p"
);
expect_eq
(
wbuf
[
0
],
0
,
WCHAR
,
"%x"
);
expect_eq
(
wbuf
[
1
],
(
WCHAR
)
0xbfbf
,
WCHAR
,
"%x"
);
memset
(
wbuf
,
0xbf
,
sizeof
(
wbuf
));
expect_eq
(
StrCpyNW
(
wbuf
,
0
,
0
),
wbuf
,
PWCHAR
,
"%p"
);
expect_eq
(
wbuf
[
0
],
(
WCHAR
)
0xbfbf
,
WCHAR
,
"%x"
);
expect_eq
(
wbuf
[
1
],
(
WCHAR
)
0xbfbf
,
WCHAR
,
"%x"
);
memset
(
wbuf
,
0xbf
,
sizeof
(
wbuf
));
expect_eq
(
StrCpyNW
(
wbuf
,
wstr1
,
0
),
wbuf
,
PWCHAR
,
"%p"
);
expect_eq
(
wbuf
[
0
],
(
WCHAR
)
0xbfbf
,
WCHAR
,
"%x"
);
expect_eq
(
wbuf
[
1
],
(
WCHAR
)
0xbfbf
,
WCHAR
,
"%x"
);
memset
(
wbuf
,
0xbf
,
sizeof
(
wbuf
));
expect_eq
(
StrCpyNW
(
wbuf
,
wstr1
,
10
),
wbuf
,
PWCHAR
,
"%p"
);
expect_eq
(
wbuf
[
9
],
0
,
WCHAR
,
"%x"
);
...
...
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