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