3bc04cb8c0814aa4441a8f361484dc7fd0656728
[feed/packages.git] / utils / screen / patches / 001-CVE-2021-26937.patch
1 Description: [CVE-2021-26937] Fix out of bounds array access
2 Author: Michael Schröder <mls@suse.de>
3 Bug-Debian: https://bugs.debian.org/982435
4 Bug: https://savannah.gnu.org/bugs/?60030
5 Bug: https://lists.gnu.org/archive/html/screen-devel/2021-02/msg00000.html
6 Bug-OSS-Security: https://www.openwall.com/lists/oss-security/2021/02/09/3
7 Origin: https://lists.gnu.org/archive/html/screen-devel/2021-02/msg00010.html
8
9 --- a/encoding.c
10 +++ b/encoding.c
11 @@ -43,7 +43,7 @@ static int encmatch __P((char *, char *
12 # ifdef UTF8
13 static int recode_char __P((int, int, int));
14 static int recode_char_to_encoding __P((int, int));
15 -static void comb_tofront __P((int, int));
16 +static void comb_tofront __P((int));
17 # ifdef DW_CHARS
18 static int recode_char_dw __P((int, int *, int, int));
19 static int recode_char_dw_to_encoding __P((int, int *, int));
20 @@ -1263,6 +1263,8 @@ int c;
21 {0x30000, 0x3FFFD},
22 };
23
24 + if (c >= 0xdf00 && c <= 0xdfff)
25 + return 1; /* dw combining sequence */
26 return ((bisearch(c, wide, sizeof(wide) / sizeof(struct interval) - 1)) ||
27 (cjkwidth &&
28 bisearch(c, ambiguous,
29 @@ -1330,11 +1332,12 @@ int c;
30 }
31
32 static void
33 -comb_tofront(root, i)
34 -int root, i;
35 +comb_tofront(i)
36 +int i;
37 {
38 for (;;)
39 {
40 + int root = i >= 0x700 ? 0x801 : 0x800;
41 debug1("bring to front: %x\n", i);
42 combchars[combchars[i]->prev]->next = combchars[i]->next;
43 combchars[combchars[i]->next]->prev = combchars[i]->prev;
44 @@ -1396,9 +1399,9 @@ struct mchar *mc;
45 {
46 /* full, recycle old entry */
47 if (c1 >= 0xd800 && c1 < 0xe000)
48 - comb_tofront(root, c1 - 0xd800);
49 + comb_tofront(c1 - 0xd800);
50 i = combchars[root]->prev;
51 - if (c1 == i + 0xd800)
52 + if (i == 0x800 || i == 0x801 || c1 == i + 0xd800)
53 {
54 /* completely full, can't recycle */
55 debug("utf8_handle_comp: completely full!\n");
56 @@ -1422,7 +1425,7 @@ struct mchar *mc;
57 mc->font = (i >> 8) + 0xd8;
58 mc->fontx = 0;
59 debug3("combinig char %x %x -> %x\n", c1, c, i + 0xd800);
60 - comb_tofront(root, i);
61 + comb_tofront(i);
62 }
63
64 #else /* !UTF8 */