From 445b607f8cf6cf1ec161c40d665502b97b6fcaac Mon Sep 17 00:00:00 2001 From: Liquor <1692257904@qq.com> Date: Fri, 26 Feb 2021 14:56:27 +0800 Subject: [PATCH] fix CVE-2021-26937 --- backport-CVE-2021-26937.patch | 61 +++++++++++++++++++++++++++++++++++ screen.spec | 17 +++++++--- 2 files changed, 73 insertions(+), 5 deletions(-) create mode 100644 backport-CVE-2021-26937.patch diff --git a/backport-CVE-2021-26937.patch b/backport-CVE-2021-26937.patch new file mode 100644 index 0000000..ba01881 --- /dev/null +++ b/backport-CVE-2021-26937.patch @@ -0,0 +1,61 @@ +Description: [CVE-2021-26937] Fix out of bounds array access +Author: Michael Schröder +Bug-Debian: https://bugs.debian.org/982435 +Bug: https://savannah.gnu.org/bugs/?60030 +Bug: https://lists.gnu.org/archive/html/screen-devel/2021-02/msg00000.html +Bug-OSS-Security: https://www.openwall.com/lists/oss-security/2021/02/09/3 +Origin: https://lists.gnu.org/archive/html/screen-devel/2021-02/msg00010.html + +--- a/encoding.c ++++ b/encoding.c +@@ -43,7 +43,7 @@ + # ifdef UTF8 + static int recode_char __P((int, int, int)); + static int recode_char_to_encoding __P((int, int)); +-static void comb_tofront __P((int, int)); ++static void comb_tofront __P((int)); + # ifdef DW_CHARS + static int recode_char_dw __P((int, int *, int, int)); + static int recode_char_dw_to_encoding __P((int, int *, int)); +@@ -1093,15 +1093,18 @@ + { 0xE0100, 0xE01EF } + }; + ++ if (c >= 0xdf00 && c <= 0xdfff) ++ return 1; /* dw combining sequence */ + return bisearch(c, combining, sizeof(combining) / sizeof(struct interval) - 1); + } + + static void +-comb_tofront(root, i) +-int root, i; ++comb_tofront(i) ++int i; + { + for (;;) + { ++ int root = i >= 0x700 ? 0x801 : 0x800; + debug1("bring to front: %x\n", i); + combchars[combchars[i]->prev]->next = combchars[i]->next; + combchars[combchars[i]->next]->prev = combchars[i]->prev; +@@ -1163,9 +1166,9 @@ + { + /* full, recycle old entry */ + if (c1 >= 0xd800 && c1 < 0xe000) +- comb_tofront(root, c1 - 0xd800); ++ comb_tofront(c1 - 0xd800); + i = combchars[root]->prev; +- if (c1 == i + 0xd800) ++ if (i == 0x800 || i == 0x801 || c1 == i + 0xd800) + { + /* completely full, can't recycle */ + debug("utf8_handle_comp: completely full!\n"); +@@ -1189,7 +1192,7 @@ + mc->font = (i >> 8) + 0xd8; + mc->fontx = 0; + debug3("combinig char %x %x -> %x\n", c1, c, i + 0xd800); +- comb_tofront(root, i); ++ comb_tofront(i); + } + + #else /* !UTF8 */ diff --git a/screen.spec b/screen.spec index 234508c..7f64c6b 100644 --- a/screen.spec +++ b/screen.spec @@ -1,17 +1,18 @@ Name: screen Epoch: 1 Version: 4.8.0 -Release: 1 +Release: 2 Summary: A full-screen window manager License: GPLv3+ URL: http://www.gnu.org/software/screen Source0: http://ftp.gnu.org/gnu/screen/screen-%{version}.tar.gz Source1: screen.pam -Patch0: screen-4.3.1-screenrc.patch -Patch1: screen-E3.patch -Patch2: screen-4.3.1-suppress_remap.patch -Patch3: screen-4.3.1-crypt.patch +Patch1: screen-4.3.1-screenrc.patch +Patch2: screen-E3.patch +Patch3: screen-4.3.1-suppress_remap.patch +Patch4: screen-4.3.1-crypt.patch +Patch5: backport-CVE-2021-26937.patch BuildRequires: automake autoconf gcc ncurses-devel texinfo Requires: shadow-utils @@ -97,6 +98,12 @@ fi %{_infodir}/screen.info* %changelog +* Fri Feb 26 2021 lirui - 1:4.8.0-2 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:fix CVE-2021-26937 + * Wed Aug 26 2020 linwei - 1:4.8.0-1 - Type:enhancement - ID:NA -- Gitee