fix CVE-2021-27135

(cherry picked from commit fbd14b8419add4e62586f9f156fd778cbdbd2ce7)
This commit is contained in:
jzm369 2021-03-03 14:53:26 +08:00 committed by openeuler-sync-bot
parent 9274f2cc0b
commit b2b7d17803
2 changed files with 70 additions and 1 deletions

View File

@ -0,0 +1,52 @@
From 82ba55b8f994ab30ff561a347b82ea340ba7075c Mon Sep 17 00:00:00 2001
From: "Thomas E. Dickey" <dickey@invisible-island.net>
Date: Tue, 9 Feb 2021 23:04:41 +0000
Subject: [PATCH] snapshot of project "xterm", label xterm-365d
--- a/button.c
+++ b/button.c
@@ -3669,6 +3669,7 @@
{
TScreen *screen = TScreenOf(xw);
int i, j = 0;
+ size_t have = 0;
int eol;
Char *line;
Char *lp;
@@ -3695,7 +3696,11 @@
/* UTF-8 may require more space */
if_OPT_WIDE_CHARS(screen, {
- j *= 4;
+ if (j > 0) {
+ if (screen->max_combining > 0)
+ j += screen->max_combining;
+ j *= 6;
+ }
});
/* now get some memory to save it in */
@@ -3732,10 +3737,20 @@
}
*lp = '\0'; /* make sure we have end marked */
- TRACE(("Salted TEXT:%d:%s\n", (int) (lp - line),
- visibleChars(line, (unsigned) (lp - line))));
+ have = (size_t) (lp - line);
+ /*
+ * Scanning the buffer twice is unnecessary. Discard unwanted memory if
+ * the estimate is too-far off.
+ */
+ if ((have * 2) < (size_t) j) {
+ screen->selection_size = have + 1;
+ line = realloc(line, screen->selection_size);
+ }
- screen->selection_length = (unsigned long) (lp - line);
+ TRACE(("Salted TEXT:%d:%s\n", (int) have,
+ visibleChars(line, (unsigned) have)));
+
+ screen->selection_length = (unsigned long) have;
}
#if OPT_PASTE64

View File

@ -1,11 +1,13 @@
Name: xterm
Version: 334
Release: 4
Release: 7
Summary: It is a terminal emulator for the X Window System
License: MIT
URL: http://invisible-island.net/xterm
Source0: http://invisible-island.net/xterm/xterm-334.tgz
Patch6000: backport-CVE-2021-27135.patch
BuildRequires: gcc git pkgconfig ncurses-devel libutempter-devel
BuildRequires: libXft-devel libXaw-devel libXext-devel desktop-file-utils
BuildRequires: libxkbfile-devel xorg-x11-apps
@ -62,6 +64,21 @@ install -m 644 -p xterm.appdata.xml %{buildroot}/%{_datadir}/appdata
%{_mandir}/man1/*
%changelog
* Wed Mar 03 2021 jinzhimin <jinzhimin2@huawei.com> - 334-7
- fix CVE-2021-27135
* Thu Sep 29 2020 hanhui <hanhui15@huawei.com> - 334-6
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:modify source url
* Thu Sep 10 2020 hanhui <hanhui15@huawei.com> - 334-5
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:modify source url
* Thu Jan 3 2020 openEuler Buildteam <buildteam@openeuler.org> - 334-4
- Type:bugfix
- ID:NA