diff options
author | Szabolcs Nagy <nsz@port70.net> | 2014-01-23 03:24:54 +0100 |
---|---|---|
committer | Szabolcs Nagy <nsz@port70.net> | 2014-01-23 03:24:54 +0100 |
commit | f1471d32166e0881dccc1d551b59238a07351668 (patch) | |
tree | 339f9d1a39f81c25e6e838cea316e71c723d96b8 /src/locale | |
parent | 59314304a0320fd3dd4caa56e2ebc625ffc46c56 (diff) | |
download | musl-f1471d32166e0881dccc1d551b59238a07351668.tar.gz musl-f1471d32166e0881dccc1d551b59238a07351668.tar.bz2 musl-f1471d32166e0881dccc1d551b59238a07351668.tar.xz musl-f1471d32166e0881dccc1d551b59238a07351668.zip |
fix an overflow in wcsxfrm when n==0
posix allows zero length destination
Diffstat (limited to 'src/locale')
-rw-r--r-- | src/locale/wcsxfrm.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/locale/wcsxfrm.c b/src/locale/wcsxfrm.c index cb79c97e..5d89e7dd 100644 --- 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; } |