projects
/
oweals
/
musl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
5931430
)
fix an overflow in wcsxfrm when n==0
author
Szabolcs Nagy
<nsz@port70.net>
Thu, 23 Jan 2014 02:24:54 +0000
(
03:24
+0100)
committer
Szabolcs Nagy
<nsz@port70.net>
Thu, 23 Jan 2014 02:24:54 +0000
(
03:24
+0100)
posix allows zero length destination
src/locale/wcsxfrm.c
patch
|
blob
|
history
diff --git
a/src/locale/wcsxfrm.c
b/src/locale/wcsxfrm.c
index cb79c97e79efdde4b0394db68c90e210950470bb..5d89e7dd522747d0167ca7e4e4e78b46ab6966cd 100644
(file)
--- a/
src/locale/wcsxfrm.c
+++ b/
src/locale/wcsxfrm.c
@@
-6,10
+6,12
@@
size_t __wcsxfrm_l(wchar_t *restrict dest, const wchar_t *restrict src, size_t n, locale_t loc)
{
size_t l = wcslen(src);
- if (l >= n) {
+ if (l < n) {
+ wmemcpy(dest, src, l+1);
+ } else if (n) {
wmemcpy(dest, src, n-1);
dest[n-1] = 0;
- }
else wcscpy(dest, src);
+ }
return l;
}