git: 5a77b3ff4c0e - main - sysutils/tmux: Fix crash when text selection using mouse

From: Koichiro Iwao <meta_at_FreeBSD.org>
Date: Fri, 14 Jun 2024 08:32:15 UTC
The branch main has been updated by meta:

URL: https://cgit.FreeBSD.org/ports/commit/?id=5a77b3ff4c0e9fed2b3dab55023735008cff1e73

commit 5a77b3ff4c0e9fed2b3dab55023735008cff1e73
Author:     Koichiro Iwao <meta@FreeBSD.org>
AuthorDate: 2024-05-24 18:15:51 +0000
Commit:     Koichiro Iwao <meta@FreeBSD.org>
CommitDate: 2024-06-14 08:31:54 +0000

    sysutils/tmux: Fix crash when text selection using mouse
    
    I re-ported a patch originally ported to 3.2a by Tobias Brick, a
    Microsoft employee to 3.3a. The patch depends on ncurses 6.4-20230423 or
    later so I bind this port to ncurses:port.
    
    See commit message of the patch for detail [1]
    
    [1] https://github.com/microsoft/azurelinux/blob/a1f78f2/SPECS/tmux/manual-patch-to-fix-crash-due-to-change-to-ncurses.patch
    
    PR:             279276
    Approved by:    maintainer timeout
    Obtained from:  https://github.com/microsoft/azurelinux/issues/6598
    Obtained from:  https://github.com/microsoft/azurelinux/pull/6766
---
 sysutils/tmux/Makefile                             |  4 +-
 ...tch-to-fix-crash-due-to-change-to-ncurses.patch | 63 ++++++++++++++++++++++
 2 files changed, 65 insertions(+), 2 deletions(-)

diff --git a/sysutils/tmux/Makefile b/sysutils/tmux/Makefile
index 0e0c0280a234..4ae211a218d3 100644
--- a/sysutils/tmux/Makefile
+++ b/sysutils/tmux/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	tmux
 PORTVERSION=	3.3a
-PORTREVISION=	2
+PORTREVISION=	3
 CATEGORIES=	sysutils
 MASTER_SITES=	https://github.com/tmux/tmux/releases/download/${PORTVERSION}/
 DISTFILES=	${DISTNAME}${EXTRACT_SUFX}
@@ -16,7 +16,7 @@ LICENSE_FILE_GPLv2=	${WRKSRC_bash}/COPYING
 LICENSE_DISTFILES_ISCL=	${DISTNAME}${EXTRACT_SUFX}
 LICENSE_DISTFILES_GPLv2=	${DISTFILE_bash}
 
-USES=		cpe ncurses pkgconfig
+USES=		cpe ncurses:port pkgconfig
 
 CPE_VENDOR=	tmux_project
 
diff --git a/sysutils/tmux/files/patch-to-fix-crash-due-to-change-to-ncurses.patch b/sysutils/tmux/files/patch-to-fix-crash-due-to-change-to-ncurses.patch
new file mode 100644
index 000000000000..00922273763c
--- /dev/null
+++ b/sysutils/tmux/files/patch-to-fix-crash-due-to-change-to-ncurses.patch
@@ -0,0 +1,63 @@
+diff --git tty-term.c tty-term.c
+index fdf0c4fa..873e1ce2 100644
+--- tty-term.c
++++ tty-term.c
+@@ -762,33 +762,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