From 0983c1f04c56f0fb314c536a7fc1fe239418050b Mon Sep 17 00:00:00 2001 From: brooks Date: Fri, 22 Jan 2016 00:08:16 +0000 Subject: [PATCH] MFC r293855: 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 Requested by: danfe git-svn-id: svn://svn.freebsd.org/base/stable/8@294537 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- lib/libc/string/wcsncat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libc/string/wcsncat.c b/lib/libc/string/wcsncat.c index 44f1ff989..5a243477d 100644 --- a/lib/libc/string/wcsncat.c +++ b/lib/libc/string/wcsncat.c @@ -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--; } -- 2.42.0