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
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));
18 static int recode_char_dw __P((int, int *, int, int));
19 static int recode_char_dw_to_encoding __P((int, int *, int));
24 + if (c >= 0xdf00 && c <= 0xdfff)
25 + return 1; /* dw combining sequence */
26 return ((bisearch(c, wide, sizeof(wide) / sizeof(struct interval) - 1)) ||
28 bisearch(c, ambiguous,
29 @@ -1330,11 +1332,12 @@
33 -comb_tofront(root, i)
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;
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)
54 /* completely full, can't recycle */
55 debug("utf8_handle_comp: completely full!\n");
57 mc->font = (i >> 8) + 0xd8;
59 debug3("combinig char %x %x -> %x\n", c1, c, i + 0xd800);
60 - comb_tofront(root, i);