From a18da6401fd8f2bbafdc7a719184ecf6aae70e6d Mon Sep 17 00:00:00 2001 From: brooks Date: Fri, 22 Jan 2016 00:13:18 +0000 Subject: [PATCH] MFC r293856: 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 Requested by: danfe git-svn-id: svn://svn.freebsd.org/base/stable/8@294538 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- lib/libc/string/wcslcat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libc/string/wcslcat.c b/lib/libc/string/wcslcat.c index f5f1e1ee7..2df94777d 100644 --- a/lib/libc/string/wcslcat.c +++ b/lib/libc/string/wcslcat.c @@ -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; -- 2.42.0