svn commit: r350526 - stable/12/lib/libc/tests/string
Brooks Davis
brooks at FreeBSD.org
Thu Aug 1 23:28:54 UTC 2019
Author: brooks
Date: Thu Aug 1 23:28:54 2019
New Revision: 350526
URL: https://svnweb.freebsd.org/changeset/base/350526
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/12/lib/libc/tests/string/wcsnlen_test.c
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/lib/libc/tests/string/wcsnlen_test.c
==============================================================================
--- stable/12/lib/libc/tests/string/wcsnlen_test.c Thu Aug 1 22:48:06 2019 (r350525)
+++ stable/12/lib/libc/tests/string/wcsnlen_test.c Thu Aug 1 23:28:54 2019 (r350526)
@@ -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);
}
More information about the svn-src-stable-12
mailing list