Author: brooks
Date: Fri Jul 19 23:58:30 2019
New Revision: 350160
URL: https://svnweb.freebsd.org/changeset/base/350160

Log:
  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
  MFC after:    1 week
  Sponsored by: DARPA, AFRL
  Differential Revision:        https://reviews.freebsd.org/D21004

Modified:
  head/lib/libc/tests/string/wcsnlen_test.c

Modified: head/lib/libc/tests/string/wcsnlen_test.c
==============================================================================
--- head/lib/libc/tests/string/wcsnlen_test.c   Fri Jul 19 23:39:21 2019        
(r350159)
+++ head/lib/libc/tests/string/wcsnlen_test.c   Fri Jul 19 23:58:30 2019        
(r350160)
@@ -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);
                }
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to