Karsten Hopp c9b1f4
To: vim-dev@vim.org
Karsten Hopp c9b1f4
Subject: Patch 7.1.202
Karsten Hopp c9b1f4
Fcc: outbox
Karsten Hopp c9b1f4
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp c9b1f4
Mime-Version: 1.0
Karsten Hopp c9b1f4
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp c9b1f4
Content-Transfer-Encoding: 8bit
Karsten Hopp c9b1f4
------------
Karsten Hopp c9b1f4
Karsten Hopp c9b1f4
Patch 7.1.202
Karsten Hopp c9b1f4
Problem:    Incomplete utf-8 byte sequence is not checked for validity.
Karsten Hopp c9b1f4
Solution:   Check the bytes that are present for being valid. (Ben Schmidt)
Karsten Hopp c9b1f4
Files:	    src/mbyte.c
Karsten Hopp c9b1f4
Karsten Hopp c9b1f4
Karsten Hopp c9b1f4
*** ../vim-7.1.201/src/mbyte.c	Thu Aug 30 13:51:52 2007
Karsten Hopp c9b1f4
--- src/mbyte.c	Fri Jan  4 17:30:16 2008
Karsten Hopp c9b1f4
***************
Karsten Hopp c9b1f4
*** 1642,1648 ****
Karsten Hopp c9b1f4
   * Get the length of UTF-8 byte sequence "p[size]".  Does not include any
Karsten Hopp c9b1f4
   * following composing characters.
Karsten Hopp c9b1f4
   * Returns 1 for "".
Karsten Hopp c9b1f4
!  * Returns 1 for an illegal byte sequence.
Karsten Hopp c9b1f4
   * Returns number > "size" for an incomplete byte sequence.
Karsten Hopp c9b1f4
   */
Karsten Hopp c9b1f4
      int
Karsten Hopp c9b1f4
--- 1642,1648 ----
Karsten Hopp c9b1f4
   * Get the length of UTF-8 byte sequence "p[size]".  Does not include any
Karsten Hopp c9b1f4
   * following composing characters.
Karsten Hopp c9b1f4
   * Returns 1 for "".
Karsten Hopp c9b1f4
!  * Returns 1 for an illegal byte sequence (also in incomplete byte seq.).
Karsten Hopp c9b1f4
   * Returns number > "size" for an incomplete byte sequence.
Karsten Hopp c9b1f4
   */
Karsten Hopp c9b1f4
      int
Karsten Hopp c9b1f4
***************
Karsten Hopp c9b1f4
*** 1652,1664 ****
Karsten Hopp c9b1f4
  {
Karsten Hopp c9b1f4
      int		len;
Karsten Hopp c9b1f4
      int		i;
Karsten Hopp c9b1f4
  
Karsten Hopp c9b1f4
      if (*p == NUL)
Karsten Hopp c9b1f4
  	return 1;
Karsten Hopp c9b1f4
!     len = utf8len_tab[*p];
Karsten Hopp c9b1f4
      if (len > size)
Karsten Hopp c9b1f4
! 	return len;	/* incomplete byte sequence. */
Karsten Hopp c9b1f4
!     for (i = 1; i < len; ++i)
Karsten Hopp c9b1f4
  	if ((p[i] & 0xc0) != 0x80)
Karsten Hopp c9b1f4
  	    return 1;
Karsten Hopp c9b1f4
      return len;
Karsten Hopp c9b1f4
--- 1652,1665 ----
Karsten Hopp c9b1f4
  {
Karsten Hopp c9b1f4
      int		len;
Karsten Hopp c9b1f4
      int		i;
Karsten Hopp c9b1f4
+     int		m;
Karsten Hopp c9b1f4
  
Karsten Hopp c9b1f4
      if (*p == NUL)
Karsten Hopp c9b1f4
  	return 1;
Karsten Hopp c9b1f4
!     m = len = utf8len_tab[*p];
Karsten Hopp c9b1f4
      if (len > size)
Karsten Hopp c9b1f4
! 	m = size;	/* incomplete byte sequence. */
Karsten Hopp c9b1f4
!     for (i = 1; i < m; ++i)
Karsten Hopp c9b1f4
  	if ((p[i] & 0xc0) != 0x80)
Karsten Hopp c9b1f4
  	    return 1;
Karsten Hopp c9b1f4
      return len;
Karsten Hopp c9b1f4
*** ../vim-7.1.201/src/version.c	Fri Jan  4 16:30:40 2008
Karsten Hopp c9b1f4
--- src/version.c	Fri Jan  4 17:45:33 2008
Karsten Hopp c9b1f4
***************
Karsten Hopp c9b1f4
*** 668,669 ****
Karsten Hopp c9b1f4
--- 668,671 ----
Karsten Hopp c9b1f4
  {   /* Add new patch number below this line */
Karsten Hopp c9b1f4
+ /**/
Karsten Hopp c9b1f4
+     202,
Karsten Hopp c9b1f4
  /**/
Karsten Hopp c9b1f4
Karsten Hopp c9b1f4
-- 
Karsten Hopp c9b1f4
A computer programmer is a device for turning requirements into
Karsten Hopp c9b1f4
undocumented features.  It runs on cola, pizza and Dilbert cartoons.
Karsten Hopp c9b1f4
					Bram Moolenaar
Karsten Hopp c9b1f4
Karsten Hopp c9b1f4
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp c9b1f4
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp c9b1f4
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp c9b1f4
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///