]>
Commit | Line | Data |
---|---|---|
d2415672 AG |
1 | To: vim-dev@vim.org |
2 | Subject: Patch 7.1.202 | |
3 | Fcc: outbox | |
4 | From: Bram Moolenaar <Bram@moolenaar.net> | |
5 | Mime-Version: 1.0 | |
6 | Content-Type: text/plain; charset=ISO-8859-1 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ------------ | |
9 | ||
10 | Patch 7.1.202 | |
11 | Problem: Incomplete utf-8 byte sequence is not checked for validity. | |
12 | Solution: Check the bytes that are present for being valid. (Ben Schmidt) | |
13 | Files: src/mbyte.c | |
14 | ||
15 | ||
16 | *** ../vim-7.1.201/src/mbyte.c Thu Aug 30 13:51:52 2007 | |
17 | --- src/mbyte.c Fri Jan 4 17:30:16 2008 | |
18 | *************** | |
19 | *** 1642,1648 **** | |
20 | * Get the length of UTF-8 byte sequence "p[size]". Does not include any | |
21 | * following composing characters. | |
22 | * Returns 1 for "". | |
23 | ! * Returns 1 for an illegal byte sequence. | |
24 | * Returns number > "size" for an incomplete byte sequence. | |
25 | */ | |
26 | int | |
27 | --- 1642,1648 ---- | |
28 | * Get the length of UTF-8 byte sequence "p[size]". Does not include any | |
29 | * following composing characters. | |
30 | * Returns 1 for "". | |
31 | ! * Returns 1 for an illegal byte sequence (also in incomplete byte seq.). | |
32 | * Returns number > "size" for an incomplete byte sequence. | |
33 | */ | |
34 | int | |
35 | *************** | |
36 | *** 1652,1664 **** | |
37 | { | |
38 | int len; | |
39 | int i; | |
40 | ||
41 | if (*p == NUL) | |
42 | return 1; | |
43 | ! len = utf8len_tab[*p]; | |
44 | if (len > size) | |
45 | ! return len; /* incomplete byte sequence. */ | |
46 | ! for (i = 1; i < len; ++i) | |
47 | if ((p[i] & 0xc0) != 0x80) | |
48 | return 1; | |
49 | return len; | |
50 | --- 1652,1665 ---- | |
51 | { | |
52 | int len; | |
53 | int i; | |
54 | + int m; | |
55 | ||
56 | if (*p == NUL) | |
57 | return 1; | |
58 | ! m = len = utf8len_tab[*p]; | |
59 | if (len > size) | |
60 | ! m = size; /* incomplete byte sequence. */ | |
61 | ! for (i = 1; i < m; ++i) | |
62 | if ((p[i] & 0xc0) != 0x80) | |
63 | return 1; | |
64 | return len; | |
65 | *** ../vim-7.1.201/src/version.c Fri Jan 4 16:30:40 2008 | |
66 | --- src/version.c Fri Jan 4 17:45:33 2008 | |
67 | *************** | |
68 | *** 668,669 **** | |
69 | --- 668,671 ---- | |
70 | { /* Add new patch number below this line */ | |
71 | + /**/ | |
72 | + 202, | |
73 | /**/ | |
74 | ||
75 | -- | |
76 | A computer programmer is a device for turning requirements into | |
77 | undocumented features. It runs on cola, pizza and Dilbert cartoons. | |
78 | Bram Moolenaar | |
79 | ||
80 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
81 | /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
82 | \\\ download, build and distribute -- http://www.A-A-P.org /// | |
83 | \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |