fix CVE-2021-26937

This commit is contained in:
Liquor 2021-02-26 14:56:27 +08:00
parent 50334b4e70
commit 3ef5601c5e
2 changed files with 73 additions and 5 deletions

View File

@ -0,0 +1,61 @@
Description: [CVE-2021-26937] Fix out of bounds array access
Author: Michael Schröder <mls@suse.de>
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 */

View File

@ -1,17 +1,18 @@
Name: screen
Epoch: 1
Version: 4.8.0
Release: 8
Release: 9
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<lirui130@huawei.com> - 1:4.8.0-9
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix CVE-2021-26937
* Mon Jul 27 2020 linwei<linwei54@huawei.com> - 1:4.8.0-8
- Type:bugfix
- ID:NA