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
e3e12845
Commit
e3e12845
authored
Aug 13, 2013
by
Álvaro Nieto
Committed by
Alexandre Julliard
Aug 16, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvrct: Fix strncpy to fill the buffer.
parent
af058929
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
string.c
dlls/msvcrt/string.c
+2
-0
string.c
dlls/msvcrt/tests/string.c
+31
-0
No files found.
dlls/msvcrt/string.c
View file @
e3e12845
...
...
@@ -581,6 +581,8 @@ char* __cdecl MSVCRT_strncpy(char *dst, const char *src, MSVCRT_size_t len)
for
(
i
=
0
;
i
<
len
;
i
++
)
if
((
dst
[
i
]
=
src
[
i
])
==
'\0'
)
break
;
while
(
i
<
len
)
dst
[
i
++
]
=
0
;
return
dst
;
}
...
...
dlls/msvcrt/tests/string.c
View file @
e3e12845
...
...
@@ -2574,6 +2574,36 @@ static void test_atoi(void)
ok
(
r
==
0
,
"atoi(4294967296) = %d
\n
"
,
r
);
}
static
void
test_strncpy
(
void
)
{
#define TEST_STRNCPY_LEN 10
char
*
ret
;
char
dst
[
TEST_STRNCPY_LEN
+
1
];
char
not_null_terminated
[]
=
{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'0'
};
/* strlen(src) > TEST_STRNCPY_LEN */
ret
=
strncpy
(
dst
,
"01234567890123456789"
,
TEST_STRNCPY_LEN
);
ok
(
ret
==
dst
,
"ret != dst
\n
"
);
ok
(
!
strncmp
(
dst
,
"0123456789"
,
TEST_STRNCPY_LEN
),
"dst != 0123456789
\n
"
);
/* without null-terminated */
ret
=
strncpy
(
dst
,
not_null_terminated
,
TEST_STRNCPY_LEN
);
ok
(
ret
==
dst
,
"ret != dst
\n
"
);
ok
(
!
strncmp
(
dst
,
"0123456789"
,
TEST_STRNCPY_LEN
),
"dst != 0123456789
\n
"
);
/* strlen(src) < TEST_STRNCPY_LEN */
strcpy
(
dst
,
"0123456789"
);
ret
=
strncpy
(
dst
,
"012345"
,
TEST_STRNCPY_LEN
);
ok
(
ret
==
dst
,
"ret != dst
\n
"
);
ok
(
!
strcmp
(
dst
,
"012345"
),
"dst != 012345
\n
"
);
ok
(
dst
[
TEST_STRNCPY_LEN
-
1
]
==
'\0'
,
"dst[TEST_STRNCPY_LEN - 1] != 0
\n
"
);
/* strlen(src) == TEST_STRNCPY_LEN */
ret
=
strncpy
(
dst
,
"0123456789"
,
TEST_STRNCPY_LEN
);
ok
(
ret
==
dst
,
"ret != dst
\n
"
);
ok
(
!
strncmp
(
dst
,
"0123456789"
,
TEST_STRNCPY_LEN
),
"dst != 0123456789
\n
"
);
}
START_TEST
(
string
)
{
char
mem
[
100
];
...
...
@@ -2675,4 +2705,5 @@ START_TEST(string)
test__stricmp
();
test__wcstoi64
();
test_atoi
();
test_strncpy
();
}
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