You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
2.1 KiB

  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. --- a/encoding.c
  9. +++ b/encoding.c
  10. @@ -43,7 +43,7 @@ static int encmatch __P((char *, char *
  11. # ifdef UTF8
  12. static int recode_char __P((int, int, int));
  13. static int recode_char_to_encoding __P((int, int));
  14. -static void comb_tofront __P((int, int));
  15. +static void comb_tofront __P((int));
  16. # ifdef DW_CHARS
  17. static int recode_char_dw __P((int, int *, int, int));
  18. static int recode_char_dw_to_encoding __P((int, int *, int));
  19. @@ -1263,6 +1263,8 @@ int c;
  20. {0x30000, 0x3FFFD},
  21. };
  22. + if (c >= 0xdf00 && c <= 0xdfff)
  23. + return 1; /* dw combining sequence */
  24. return ((bisearch(c, wide, sizeof(wide) / sizeof(struct interval) - 1)) ||
  25. (cjkwidth &&
  26. bisearch(c, ambiguous,
  27. @@ -1330,11 +1332,12 @@ int c;
  28. }
  29. static void
  30. -comb_tofront(root, i)
  31. -int root, i;
  32. +comb_tofront(i)
  33. +int i;
  34. {
  35. for (;;)
  36. {
  37. + int root = i >= 0x700 ? 0x801 : 0x800;
  38. debug1("bring to front: %x\n", i);
  39. combchars[combchars[i]->prev]->next = combchars[i]->next;
  40. combchars[combchars[i]->next]->prev = combchars[i]->prev;
  41. @@ -1396,9 +1399,9 @@ struct mchar *mc;
  42. {
  43. /* full, recycle old entry */
  44. if (c1 >= 0xd800 && c1 < 0xe000)
  45. - comb_tofront(root, c1 - 0xd800);
  46. + comb_tofront(c1 - 0xd800);
  47. i = combchars[root]->prev;
  48. - if (c1 == i + 0xd800)
  49. + if (i == 0x800 || i == 0x801 || c1 == i + 0xd800)
  50. {
  51. /* completely full, can't recycle */
  52. debug("utf8_handle_comp: completely full!\n");
  53. @@ -1422,7 +1425,7 @@ struct mchar *mc;
  54. mc->font = (i >> 8) + 0xd8;
  55. mc->fontx = 0;
  56. debug3("combinig char %x %x -> %x\n", c1, c, i + 0xd800);
  57. - comb_tofront(root, i);
  58. + comb_tofront(i);
  59. }
  60. #else /* !UTF8 */