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:		206178
Submitted by:	Alexander Cherepanov <cherepan@mccme.ru>
MFC after:	1 week
This commit is contained in:
Brooks Davis 2016-01-13 21:50:08 +00:00
parent cd3dbc2573
commit 216818a1bb
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=293856

View File

@ -54,7 +54,7 @@ wcslcat(wchar_t *dst, const wchar_t *src, size_t siz)
size_t dlen;
/* Find the end of dst and adjust bytes left but don't go past end */
while (*d != '\0' && n-- != 0)
while (n-- != 0 && *d != '\0')
d++;
dlen = d - dst;
n = siz - dlen;