提交 f1471d32 编写于 作者: S Szabolcs Nagy

fix an overflow in wcsxfrm when n==0

posix allows zero length destination
上级 59314304
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册