diff --git a/ksh-1.0.9-no-TERM-env-segfault.patch b/ksh-1.0.9-no-TERM-env-segfault.patch new file mode 100644 index 0000000..53fc1f3 --- /dev/null +++ b/ksh-1.0.9-no-TERM-env-segfault.patch @@ -0,0 +1,59 @@ +From 26eec44e33ed4a48cb7ba34706d96387385d1980 Mon Sep 17 00:00:00 2001 +From: Johnothan King +Date: Thu, 22 Feb 2024 15:26:57 -0800 +Subject: [PATCH] Fix segfault on starting ksh with no TERM env var (#723) + +This commit fixes a crash that prevented ksh from starting up in +single user mode on DragonFlyBSD and NetBSD. + +src/cmd/ksh93/edit/edit.c: +- Make sure the np node for $TERM is not null before checking for + an export attribute. + +Co-authored-by: Martijn Dekker +Resolves: https://github.com/ksh93/ksh/issues/722 +--- + src/cmd/ksh93/edit/edit.c | 2 +- + src/cmd/ksh93/tests/pty.sh | 14 ++++++++++++++ + 2 files changed, 15 insertions(+), 1 deletion(-) + +diff --git a/src/cmd/ksh93/edit/edit.c b/src/cmd/ksh93/edit/edit.c +index 32e1e83..0ac54ba 100644 +--- a/src/cmd/ksh93/edit/edit.c ++++ b/src/cmd/ksh93/edit/edit.c +@@ -614,7 +614,7 @@ void ed_setup(Edit_t *ep, int fd, int reedit) + static char *oldterm; + Namval_t *np = nv_search("TERM",sh.var_tree,0); + char *term = NULL; +- if(nv_isattr(np,NV_EXPORT)) ++ if(np && nv_isattr(np,NV_EXPORT)) + term = nv_getval(np); + if(!term) + term = ""; +diff --git a/src/cmd/ksh93/tests/pty.sh b/src/cmd/ksh93/tests/pty.sh +index 5dbdf6c..b4f8e28 100755 +--- a/src/cmd/ksh93/tests/pty.sh ++++ b/src/cmd/ksh93/tests/pty.sh +@@ -1255,5 +1255,19 @@ w _ksh_93u_m_cmdcompl\t + r :test-2: _ksh_93u_m_cmdcomplete_test_ \r\n$ + ! + ++((multiline && (SHOPT_VSH || SHOPT_ESH))) && TERM=vt100 tst $LINENO <<"!" ++L crash when TERM is undefined ++# https://github.com/ksh93/ksh/issues/722 ++ ++d 40 ++p :test-1: ++w unset TERM ++p :test-2: ++w "$SHELL" ++p :test-3: ++w print Exit status $? ++u ^Exit status 0\r\n$ ++! ++ + # ====== + exit $((Errors<125?Errors:125)) +-- +2.49.0 + diff --git a/ksh.spec b/ksh.spec index 99dac15..4d1755b 100644 --- a/ksh.spec +++ b/ksh.spec @@ -4,7 +4,7 @@ URL: http://www.kornshell.com/ License: EPL-1.0 Epoch: 3 Version: 1.0.6 -Release: 7%{?dist} +Release: 8%{?dist} Source0: https://github.com/ksh93/%{name}/archive/v%{version}/%{name}-%{version}.tar.gz Source1: kshcomp.conf Source2: kshrc.rhs @@ -38,6 +38,10 @@ Patch7: ksh-1.0.11-redir.patch #upstream commit: https://github.com/ksh93/ksh/commit/6668c3eb0bdc48335120e7c48590ab46af0ef0f3 Patch8: ksh-1.0.10-pjob.patch +#upstream commit: https://github.com/ksh93/ksh/commit/b15f63284bcd656729be61be6434376876be5bfc +#upstream commit: https://github.com/ksh93/ksh/commit/5e3a169785139809f1f733314f5660769c86d10c (test fix) +Patch9: ksh-1.0.9-no-TERM-env-segfault.patch + Conflicts: pdksh Requires: coreutils, diffutils BuildRequires: gcc @@ -159,6 +163,10 @@ fi %config(noreplace) %{_sysconfdir}/binfmt.d/kshcomp.conf %changelog +* Sat Mar 29 2025 Vincent Mihalkovic - 3:1.0.6-8 +- Fix segfault on starting ksh with no TERM env var + Resolves: RHEL-83283 + * Mon Feb 17 2025 Vincent Mihalkovic - 3:1.0.6-7 - Change p_job variable type from short to int Resolves: RHEL-64299