Co-authored-by: Henry Beberman <henry.beberman@microsoft.com>

Fixes issue #6598 which is a crash on selection in tmux. The fix requires an update to ncurses and a patch to tmux. From the patch comments:

```
ncurses-6.4-20230408 change tparm to require cur_term, which broke tmux usage of it.

ncurses-6.4-20230423 then added tiparm_s that allows usage without cur_term.

tmux change 39d41d0810 uses tiparm_s if it exists, but cannot be cleanly applied to tmux tag 3.2a.

That change uses a config setting to created #defines to determine which version of tparm it should use, and only conditionally uses tiparm_s, because it needs to be backwards compatible with previous versions of ncurses.

But to use that, we would need to get the actual source as it appears in github, rather than the released version (they are different downloads: see https://github.com/tmux/tmux/releases).

Fortunately, we have the luxery of forcing tmux to use a version of ncurses that has the function we want (see above).

Given all this, this patch takes the change to use tiparm_s, removes the conditional compilation portion so it always uses tiparm_s and applies it to the code as it exists in 3.2a.

It has both a build-time and run-time dependency on ncurses-6.4-20230423 or later.
```
This commit is contained in:
Tobias Brick 2023-11-16 11:49:58 -08:00 коммит произвёл GitHub
Родитель e47df523d1
Коммит 9dc4183cf8
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
9 изменённых файлов: 129 добавлений и 29 удалений

Просмотреть файл

@ -1,5 +1,5 @@
{
"Signatures": {
"ncurses-6.4-20230408.tgz": "46030c04cfb60433db05631e8124640acff284b1d3b9c897ff661686d885e0e8"
"ncurses-6.4-20230423.tgz": "7d77f95eff470099cfb7cabd6d3b8766ee1c4bda33755dd5a4d73fcc85315a4f"
}
}

Просмотреть файл

@ -1,9 +1,9 @@
%global patchlevel 20230408
%global patchlevel 20230423
Summary: Libraries for terminal handling of character screens
Name: ncurses
Version: 6.4
Release: 1%{?dist}
Release: 2%{?dist}
License: MIT
Vendor: Microsoft Corporation
Distribution: Mariner
@ -233,6 +233,9 @@ xz NEWS
%files term -f terms.term
%changelog
* Thu Nov 16 2023 Tobias Brick <tobiasb@microsoft.com> - 6.4-2
- Update to version 6.4-20230423 to fix crash in tmux
* Wed Apr 26 2023 Sindhu Karri <lakarri@microsoft.com> - 6.4-1
- Update to version 6.4-20230408 to fix CVE-2023-29491

Просмотреть файл

@ -0,0 +1,90 @@
From 8bec5e2d2e5a6c77ce3c2ec2c38e658efc6fc26f Mon Sep 17 00:00:00 2001
From: Tobias Brick <tobiasb@microsoft.com>
Date: Thu, 26 Oct 2023 17:23:48 +0000
Subject: [PATCH] Manual patch to fix crash due to change to ncurses
ncurses-6.4-20230408 change tparm to require cur_term, which broke tmux usage of it.
ncurses-6.4-20230423 then added tiparm_s that allows usage without cur_term.
tmux change https://github.com/tmux/tmux/commit/39d41d0810d4e8ae6ce8d27776dfbb96722d9319 uses tiparm_s if it exists, but cannot be cleanly applied to tmux tag 3.2a.
That change uses a config setting to created #defines to determine which version of tparm it should use, and only conditionally uses tiparm_s, because it needs to be backwards compatible with previous versions of ncurses.
But to use that, we would need to get the actual source as it appears in github, rather than the released version (they are different downloads: see https://github.com/tmux/tmux/releases).
Fortunately, we have the luxury of forcing tmux to use a version of ncurses that has the function we want (see above).
Given all this, this patch takes the change to use tiparm_s, removes the conditional compilation portion so it always uses tiparm_s and applies it to the code as it exists in 3.2a.
It has both a build-time and run-time dependency on ncurses-6.4-20230423 or later.
---
tty-term.c | 30 +++++++++++++++++++++++++-----
1 file changed, 25 insertions(+), 5 deletions(-)
diff --git a/tty-term.c b/tty-term.c
index add71d89..a5ed1d77 100644
--- a/tty-term.c
+++ b/tty-term.c
@@ -761,33 +761,53 @@ tty_term_string(struct tty_term *term, enum tty_code_code code)
const char *
tty_term_string1(struct tty_term *term, enum tty_code_code code, int a)
{
- return (tparm((char *) tty_term_string(term, code), a, 0, 0, 0, 0, 0, 0, 0, 0));
+ const char *x = tty_term_string(term, code), *s;
+ s = tiparm_s(1, 0, x, a);
+ if (s == NULL)
+ fatalx("could not expand %s", tty_term_codes[code].name);
+ return (s);
}
const char *
tty_term_string2(struct tty_term *term, enum tty_code_code code, int a, int b)
{
- return (tparm((char *) tty_term_string(term, code), a, b, 0, 0, 0, 0, 0, 0, 0));
+ const char *x = tty_term_string(term, code), *s;
+ s = tiparm_s(2, 0, x, a, b);
+ if (s == NULL)
+ fatalx("could not expand %s", tty_term_codes[code].name);
+ return (s);
}
const char *
tty_term_string3(struct tty_term *term, enum tty_code_code code, int a, int b,
int c)
{
- return (tparm((char *) tty_term_string(term, code), a, b, c, 0, 0, 0, 0, 0, 0));
+ const char *x = tty_term_string(term, code), *s;
+ s = tiparm_s(3, 0, x, a, b, c);
+ if (s == NULL)
+ fatalx("could not expand %s", tty_term_codes[code].name);
+ return (s);
}
const char *
tty_term_ptr1(struct tty_term *term, enum tty_code_code code, const void *a)
{
- return (tparm((char *) tty_term_string(term, code), (long)a, 0, 0, 0, 0, 0, 0, 0, 0));
+ const char *x = tty_term_string(term, code), *s;
+ s = tiparm_s(1, 1, x, a);
+ if (s == NULL)
+ fatalx("could not expand %s", tty_term_codes[code].name);
+ return (s);
}
const char *
tty_term_ptr2(struct tty_term *term, enum tty_code_code code, const void *a,
const void *b)
{
- return (tparm((char *) tty_term_string(term, code), (long)a, (long)b, 0, 0, 0, 0, 0, 0, 0));
+ const char *x = tty_term_string(term, code), *s;
+ s = tiparm_s(2, 3, x, a, b);
+ if (s == NULL)
+ fatalx("could not expand %s", tty_term_codes[code].name);
+ return (s);
}
int
--
2.33.8

Просмотреть файл

@ -1,7 +1,7 @@
Summary: Terminal multiplexer
Name: tmux
Version: 3.2a
Release: 3%{?dist}
Release: 4%{?dist}
License: ISC and BSD
URL: https://tmux.github.io/
Group: Applications/System
@ -9,8 +9,11 @@ Vendor: Microsoft Corporation
Distribution: Mariner
Source0: https://github.com/tmux/tmux/releases/download/%{version}/%{name}-%{version}.tar.gz
Patch0: CVE-2022-47016.patch
Requires: libevent ncurses
BuildRequires: libevent-devel ncurses-devel
Patch1: manual-patch-to-fix-crash-due-to-change-to-ncurses.patch
Requires: libevent
Requires: ncurses >= 6.4-2
BuildRequires: libevent-devel
BuildRequires: ncurses-devel >= 6.4-2
%description
Terminal multiplexer
@ -38,6 +41,10 @@ make %{?_smp_mflags} check
%exclude /usr/src
%changelog
* Thu Nov 16 2023 Tobias Brick <tobiasb@microsoft.com> - 3.2a-4
- Add dependency on ncurses >= 6.4-2
- Patch to fix crash due to kprevious change to ncurses
* Fri Feb 10 2023 Rachel Menge <rachelmenge@microsoft.com> - 3.2a-3
- Patch CVE-2022-47016

Просмотреть файл

@ -14054,7 +14054,7 @@
"other": {
"name": "ncurses",
"version": "6.4",
"downloadUrl": "https://invisible-mirror.net/archives/ncurses/current/ncurses-6.4-20230408.tgz"
"downloadUrl": "https://invisible-mirror.net/archives/ncurses/current/ncurses-6.4-20230423.tgz"
}
}
},

Просмотреть файл

@ -33,11 +33,11 @@ libpkgconf-1.8.0-3.cm2.aarch64.rpm
pkgconf-1.8.0-3.cm2.aarch64.rpm
pkgconf-m4-1.8.0-3.cm2.noarch.rpm
pkgconf-pkg-config-1.8.0-3.cm2.aarch64.rpm
ncurses-6.4-1.cm2.aarch64.rpm
ncurses-compat-6.4-1.cm2.aarch64.rpm
ncurses-devel-6.4-1.cm2.aarch64.rpm
ncurses-libs-6.4-1.cm2.aarch64.rpm
ncurses-term-6.4-1.cm2.aarch64.rpm
ncurses-6.4-2.cm2.aarch64.rpm
ncurses-compat-6.4-2.cm2.aarch64.rpm
ncurses-devel-6.4-2.cm2.aarch64.rpm
ncurses-libs-6.4-2.cm2.aarch64.rpm
ncurses-term-6.4-2.cm2.aarch64.rpm
readline-8.1-1.cm2.aarch64.rpm
readline-devel-8.1-1.cm2.aarch64.rpm
coreutils-8.32-7.cm2.aarch64.rpm

Просмотреть файл

@ -33,11 +33,11 @@ libpkgconf-1.8.0-3.cm2.x86_64.rpm
pkgconf-1.8.0-3.cm2.x86_64.rpm
pkgconf-m4-1.8.0-3.cm2.noarch.rpm
pkgconf-pkg-config-1.8.0-3.cm2.x86_64.rpm
ncurses-6.4-1.cm2.x86_64.rpm
ncurses-compat-6.4-1.cm2.x86_64.rpm
ncurses-devel-6.4-1.cm2.x86_64.rpm
ncurses-libs-6.4-1.cm2.x86_64.rpm
ncurses-term-6.4-1.cm2.x86_64.rpm
ncurses-6.4-2.cm2.x86_64.rpm
ncurses-compat-6.4-2.cm2.x86_64.rpm
ncurses-devel-6.4-2.cm2.x86_64.rpm
ncurses-libs-6.4-2.cm2.x86_64.rpm
ncurses-term-6.4-2.cm2.x86_64.rpm
readline-8.1-1.cm2.x86_64.rpm
readline-devel-8.1-1.cm2.x86_64.rpm
coreutils-8.32-7.cm2.x86_64.rpm

Просмотреть файл

@ -249,12 +249,12 @@ mpfr-4.1.0-2.cm2.aarch64.rpm
mpfr-debuginfo-4.1.0-2.cm2.aarch64.rpm
mpfr-devel-4.1.0-2.cm2.aarch64.rpm
msopenjdk-11-11.0.18-1.aarch64.rpm
ncurses-6.4-1.cm2.aarch64.rpm
ncurses-compat-6.4-1.cm2.aarch64.rpm
ncurses-debuginfo-6.4-1.cm2.aarch64.rpm
ncurses-devel-6.4-1.cm2.aarch64.rpm
ncurses-libs-6.4-1.cm2.aarch64.rpm
ncurses-term-6.4-1.cm2.aarch64.rpm
ncurses-6.4-2.cm2.aarch64.rpm
ncurses-compat-6.4-2.cm2.aarch64.rpm
ncurses-debuginfo-6.4-2.cm2.aarch64.rpm
ncurses-devel-6.4-2.cm2.aarch64.rpm
ncurses-libs-6.4-2.cm2.aarch64.rpm
ncurses-term-6.4-2.cm2.aarch64.rpm
newt-0.52.21-5.cm2.aarch64.rpm
newt-debuginfo-0.52.21-5.cm2.aarch64.rpm
newt-devel-0.52.21-5.cm2.aarch64.rpm

Просмотреть файл

@ -249,12 +249,12 @@ mpfr-4.1.0-2.cm2.x86_64.rpm
mpfr-debuginfo-4.1.0-2.cm2.x86_64.rpm
mpfr-devel-4.1.0-2.cm2.x86_64.rpm
msopenjdk-11-11.0.18-1.x86_64.rpm
ncurses-6.4-1.cm2.x86_64.rpm
ncurses-compat-6.4-1.cm2.x86_64.rpm
ncurses-debuginfo-6.4-1.cm2.x86_64.rpm
ncurses-devel-6.4-1.cm2.x86_64.rpm
ncurses-libs-6.4-1.cm2.x86_64.rpm
ncurses-term-6.4-1.cm2.x86_64.rpm
ncurses-6.4-2.cm2.x86_64.rpm
ncurses-compat-6.4-2.cm2.x86_64.rpm
ncurses-debuginfo-6.4-2.cm2.x86_64.rpm
ncurses-devel-6.4-2.cm2.x86_64.rpm
ncurses-libs-6.4-2.cm2.x86_64.rpm
ncurses-term-6.4-2.cm2.x86_64.rpm
newt-0.52.21-5.cm2.x86_64.rpm
newt-debuginfo-0.52.21-5.cm2.x86_64.rpm
newt-devel-0.52.21-5.cm2.x86_64.rpm