Author: brooks
Date: Wed Jan 13 21:50:08 2016
New Revision: 293856
URL: https://svnweb.freebsd.org/changeset/base/293856

Log:
  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 <chere...@mccme.ru>
  MFC after:    1 week

Modified:
  head/lib/libc/string/wcslcat.c

Modified: head/lib/libc/string/wcslcat.c
==============================================================================
--- head/lib/libc/string/wcslcat.c      Wed Jan 13 21:49:01 2016        
(r293855)
+++ head/lib/libc/string/wcslcat.c      Wed Jan 13 21:50:08 2016        
(r293856)
@@ -54,7 +54,7 @@ wcslcat(wchar_t *dst, const wchar_t *src
        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;
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to