Avoid reading pass the end of the source buffer when it is not NUL

terminated.

If this buffer is adjacent to an unmapped page or a version of C with
bounds checked is used this may result in a crash.

PR:		206177
Submitted by:	Alexander Cherepanov <cherepan@mccme.ru>
MFC after:	1 week
This commit is contained in:
Brooks Davis 2016-01-13 21:49:01 +00:00
parent e12a9f251e
commit cd3dbc2573
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=293855

View File

@ -48,7 +48,7 @@ wcsncat(wchar_t * __restrict s1, const wchar_t * __restrict s2, size_t n)
p++;
q = p;
r = s2;
while (*r && n) {
while (n && *r) {
*q++ = *r++;
n--;
}