Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 Aug 2019 16:05:36 +0000 (UTC)
From:      Brooks Davis <brooks@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r350539 - stable/11/lib/libc/tests/string
Message-ID:  <201908021605.x72G5aAi056084@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: brooks
Date: Fri Aug  2 16:05:36 2019
New Revision: 350539
URL: https://svnweb.freebsd.org/changeset/base/350539

Log:
  MFC r350160:
  
  Avoid copying too much from the input string.
  
  This avoids reading past the end of the static strings.  On a system
  with bounds checking these tests fault.
  
  Reviewed by:	asomers
  Obtained from:	CheriBSD
  Sponsored by:	DARPA, AFRL
  Differential Revision:	https://reviews.freebsd.org/D21004

Modified:
  stable/11/lib/libc/tests/string/wcsnlen_test.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/lib/libc/tests/string/wcsnlen_test.c
==============================================================================
--- stable/11/lib/libc/tests/string/wcsnlen_test.c	Fri Aug  2 15:19:11 2019	(r350538)
+++ stable/11/lib/libc/tests/string/wcsnlen_test.c	Fri Aug  2 16:05:36 2019	(r350539)
@@ -65,7 +65,7 @@ test_wcsnlen(const wchar_t *s)
 	for (i = 0; i <= 1; i++) {
 		for (bufsize = 0; bufsize <= size + 10; bufsize++) {
 			s1 = makebuf(bufsize * sizeof(wchar_t), i);
-			wmemcpy(s1, s, bufsize);
+			wmemcpy(s1, s, bufsize <= size ? bufsize : size);
 			len = (size > bufsize) ? bufsize : size - 1;
 			ATF_CHECK(wcsnlen(s1, bufsize) == len);
 		}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201908021605.x72G5aAi056084>