diff --git a/0003-zsh-fix-module-loading-problem-with-full-RELRO.patch b/0003-zsh-fix-module-loading-problem-with-full-RELRO.patch new file mode 100644 index 0000000000000000000000000000000000000000..2ca953b2079dd3a95a9b33a17b56621077ddf5ae --- /dev/null +++ b/0003-zsh-fix-module-loading-problem-with-full-RELRO.patch @@ -0,0 +1,69 @@ +From a84fdd7c8f77935ecce99ff2b0bdba738821ed79 Mon Sep 17 00:00:00 2001 +From: Jun-ichi Takimoto +Date: Mon, 26 Jun 2023 17:13:04 +0900 +Subject: [PATCH] 51889: fix module loading problem with full RELRO + +If full RELRO (relocation read-only, one of the security enhancement +methods for ELF-based systems) is used when building zsh (as in binary +packages of most Linuxes), loading a module (e.g. zsh/zftp) fails unless +all the modules it depends on are already loaded. With this patch the +necessary modules are automatically loaded. + +Upstream-commit: a84fdd7c8f77935ecce99ff2b0bdba738821ed79 +Signed-off-by: Lukáš Zaoral +--- + Src/Modules/zftp.c | 2 +- + Src/mkbltnmlst.sh | 24 ++++++++++++++++++++++++ + 2 files changed, 25 insertions(+), 1 deletion(-) + +diff --git a/Src/Modules/zftp.c b/Src/Modules/zftp.c +index 49b3ffa89..47a5e9de9 100644 +--- a/Src/Modules/zftp.c ++++ b/Src/Modules/zftp.c +@@ -3172,7 +3172,7 @@ static struct features module_features = { + int + setup_(UNUSED(Module m)) + { +- return (require_module("zsh/net/tcp", NULL, 0) == 1); ++ return 0; + } + + /**/ +diff --git a/Src/mkbltnmlst.sh b/Src/mkbltnmlst.sh +index c4611d8b3..067ecdaf9 100644 +--- a/Src/mkbltnmlst.sh ++++ b/Src/mkbltnmlst.sh +@@ -76,6 +76,30 @@ for x_mod in $x_mods; do + test "x$linked" = xno && echo "#endif" + done + ++# if dynamic module 'mod' with load=no has moddeps in its .mdd, ++# then output add_dep(mod, dep) for each 'dep' in moddeps. ++dyn_mods="`grep ' link=dynamic .* load=no ' $CFMOD | \ ++ sed -e '/^#/d' -e 's/ .*/ /' -e 's/^name=/ /'`" ++ ++for mod in $dyn_mods; do ++ modfile="`grep '^name='$mod' ' $CFMOD | \ ++ sed -e 's/^.* modfile=//' -e 's/ .*//'`" ++ if test "x$modfile" = x; then ++ echo >&2 "WARNING: no name for \`$mod' in $CFMOD (ignored)" ++ continue ++ fi ++ unset moddeps ++ . $srcdir/../$modfile ++ if test -n "$moddeps"; then ++ echo '#ifdef DYNAMIC' ++ echo "/* non-linked-in known module \`$mod' */" ++ for dep in $moddeps; do ++ echo " add_dep(\"$mod\", \"$dep\");" ++ done ++ echo '#endif' ++ fi ++done ++ + echo + done_mods=" " + for bin_mod in $bin_mods; do +-- +2.41.0 + diff --git a/0004-zsh-enable-PCRE-locale-switching.patch b/0004-zsh-enable-PCRE-locale-switching.patch new file mode 100644 index 0000000000000000000000000000000000000000..a6f03bf58c9c423d1f76a72a55f975ffb4ae5490 --- /dev/null +++ b/0004-zsh-enable-PCRE-locale-switching.patch @@ -0,0 +1,64 @@ +From 1b421e4978440234fb73117c8505dad1ccc68d46 Mon Sep 17 00:00:00 2001 +From: Jun-ichi Takimoto +Date: Mon, 26 Sep 2022 10:52:50 +0900 +Subject: [PATCH] 50658 + test: Enable to switch between C/UTF-8 locales in + PCRE + +--- + Src/Modules/pcre.c | 10 ++-------- + Test/V07pcre.ztst | 11 +++++++++++ + 2 files changed, 13 insertions(+), 8 deletions(-) + +diff --git a/Src/Modules/pcre.c b/Src/Modules/pcre.c +index 6289e003e..46875a59b 100644 +--- a/Src/Modules/pcre.c ++++ b/Src/Modules/pcre.c +@@ -47,8 +47,6 @@ zpcre_utf8_enabled(void) + #if defined(MULTIBYTE_SUPPORT) && defined(HAVE_NL_LANGINFO) && defined(CODESET) + static int have_utf8_pcre = -1; + +- /* value can toggle based on MULTIBYTE, so don't +- * be too eager with caching */ + if (have_utf8_pcre < -1) + return 0; + +@@ -56,15 +54,11 @@ zpcre_utf8_enabled(void) + return 0; + + if ((have_utf8_pcre == -1) && +- (!strcmp(nl_langinfo(CODESET), "UTF-8"))) { +- +- if (pcre_config(PCRE_CONFIG_UTF8, &have_utf8_pcre)) ++ (pcre_config(PCRE_CONFIG_UTF8, &have_utf8_pcre))) { + have_utf8_pcre = -2; /* erk, failed to ask */ + } + +- if (have_utf8_pcre < 0) +- return 0; +- return have_utf8_pcre; ++ return (have_utf8_pcre == 1) && (!strcmp(nl_langinfo(CODESET), "UTF-8")); + + #else + return 0; +diff --git a/Test/V07pcre.ztst b/Test/V07pcre.ztst +index ca13419e5..22a0b64c7 100644 +--- a/Test/V07pcre.ztst ++++ b/Test/V07pcre.ztst +@@ -162,3 +162,14 @@ + echo $match[2] ) + 0:regression for segmentation fault, workers/38307 + >test ++ ++ LANG_SAVE=$LANG ++ [[ é =~ '^.\z' ]]; echo $? ++ LANG=C ++ [[ é =~ '^..\z' ]]; echo $? ++ LANG=$LANG_SAVE ++ [[ é =~ '^.\z' ]]; echo $? ++0:swich between C/UTF-8 locales ++>0 ++>0 ++>0 +-- +2.41.0 + diff --git a/0007-zsh-configure-c99.patch b/0007-zsh-configure-c99.patch new file mode 100644 index 0000000000000000000000000000000000000000..c4b36231b0dc6c7e2047a0174cd9fc743b84bf61 --- /dev/null +++ b/0007-zsh-configure-c99.patch @@ -0,0 +1,44 @@ +Avoid incompatible pointer types in terminfo global variable checks. +Some compilers reject these incompatible pointer types, causing the +checks to always fail, when these variables are in fact available. + +Submitted upstream: + +diff --git a/configure.ac b/configure.ac +index a58242f453b4a8f3..5534f42df14eb28c 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1769,27 +1769,27 @@ if test x$zsh_cv_path_term_header != xnone; then + fi + + AC_MSG_CHECKING(if boolcodes is available) +- AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = boolcodes; puts(*test);]])],[AC_DEFINE(HAVE_BOOLCODES) boolcodes=yes],[boolcodes=no]) ++ AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)boolcodes; puts(*test);]])],[AC_DEFINE(HAVE_BOOLCODES) boolcodes=yes],[boolcodes=no]) + AC_MSG_RESULT($boolcodes) + + AC_MSG_CHECKING(if numcodes is available) +- AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = numcodes; puts(*test);]])],[AC_DEFINE(HAVE_NUMCODES) numcodes=yes],[numcodes=no]) ++ AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)numcodes; puts(*test);]])],[AC_DEFINE(HAVE_NUMCODES) numcodes=yes],[numcodes=no]) + AC_MSG_RESULT($numcodes) + + AC_MSG_CHECKING(if strcodes is available) +- AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = strcodes; puts(*test);]])],[AC_DEFINE(HAVE_STRCODES) strcodes=yes],[strcodes=no]) ++ AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)strcodes; puts(*test);]])],[AC_DEFINE(HAVE_STRCODES) strcodes=yes],[strcodes=no]) + AC_MSG_RESULT($strcodes) + + AC_MSG_CHECKING(if boolnames is available) +- AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = boolnames; puts(*test);]])],[AC_DEFINE(HAVE_BOOLNAMES) boolnames=yes],[boolnames=no]) ++ AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)boolnames; puts(*test);]])],[AC_DEFINE(HAVE_BOOLNAMES) boolnames=yes],[boolnames=no]) + AC_MSG_RESULT($boolnames) + + AC_MSG_CHECKING(if numnames is available) +- AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = numnames; puts(*test);]])],[AC_DEFINE(HAVE_NUMNAMES) numnames=yes],[numnames=no]) ++ AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)numnames; puts(*test);]])],[AC_DEFINE(HAVE_NUMNAMES) numnames=yes],[numnames=no]) + AC_MSG_RESULT($numnames) + + AC_MSG_CHECKING(if strnames is available) +- AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = strnames; puts(*test);]])],[AC_DEFINE(HAVE_STRNAMES) strnames=yes],[strnames=no]) ++ AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)strnames; puts(*test);]])],[AC_DEFINE(HAVE_STRNAMES) strnames=yes],[strnames=no]) + AC_MSG_RESULT($strnames) + + dnl There are apparently defective terminal library headers on some diff --git a/0008-zsh-deletefilelist-segfault.patch b/0008-zsh-deletefilelist-segfault.patch new file mode 100644 index 0000000000000000000000000000000000000000..8abaab1be4e5b41914a04930596943e47833e5dd --- /dev/null +++ b/0008-zsh-deletefilelist-segfault.patch @@ -0,0 +1,42 @@ +From d3edf318306e37d2d96c4e4ea442d10207722e94 Mon Sep 17 00:00:00 2001 +From: Bart Schaefer +Date: Sun, 12 Feb 2023 09:52:39 -0800 +Subject: [PATCH] 51404: Nullify filelist after deleting (fix segfault) + +Cherry-picked-by: Lukáš Zaoral +Upstream-commit: d3edf318306e37d2d96c4e4ea442d10207722e94 +--- + Src/jobs.c | 8 ++++++-- + 1 files changed, 6 insertions(+), 2 deletions(-) + +diff --git a/Src/jobs.c b/Src/jobs.c +index 4863962b9..59ddd952e 100644 +--- a/Src/jobs.c ++++ b/Src/jobs.c +@@ -1372,8 +1372,10 @@ cleanfilelists(void) + + DPUTS(shell_exiting >= 0, "BUG: cleanfilelists() before exit"); + +- for (i = 1; i <= maxjob; i++) ++ for (i = 1; i <= maxjob; i++) { + deletefilelist(jobtab[i].filelist, 0); ++ jobtab[i].filelist = 0; ++ } + } + + /**/ +@@ -1531,8 +1533,10 @@ havefiles(void) + int i; + + for (i = 1; i <= maxjob; i++) +- if (jobtab[i].stat && jobtab[i].filelist) ++ if (jobtab[i].stat && jobtab[i].filelist && ++ peekfirst(jobtab[i].filelist)) { + return 1; ++ } + return 0; + + } +-- +2.43.0 + diff --git a/zsh.spec b/zsh.spec index 1e182a75aa380c5e9c4600ccf18a94813d74c2c2..a3720877f824851e6857ca505c86704c3ccac182 100644 --- a/zsh.spec +++ b/zsh.spec @@ -1,8 +1,8 @@ -%define anolis_release 2 +%define anolis_release 3 Summary: Powerful interactive shell Name: zsh -Version: 5.9 +Version: 5.9 Release: %{anolis_release}%{?dist} License: MIT URL: http://zsh.sourceforge.net/ @@ -17,6 +17,10 @@ Source7: dotzprofile # do not use egrep in tests to make them pass again Patch1: 0001-zsh-5.9-do-not-use-egrep-in-tests.patch +Patch2: 0003-zsh-fix-module-loading-problem-with-full-RELRO.patch +Patch3: 0008-zsh-deletefilelist-segfault.patch +Patch4: 0004-zsh-enable-PCRE-locale-switching.patch +Patch5: 0007-zsh-configure-c99.patch BuildRequires: autoconf BuildRequires: coreutils @@ -34,6 +38,7 @@ BuildRequires: texinfo Requires(post): grep Requires(postun): coreutils grep BuildRequires: hostname +BuildRequires: pcre2-devel Provides: /bin/zsh @@ -149,6 +154,11 @@ fi %doc NEWS Etc/zsh-development-guide Etc/completion-style-guide %changelog +* Thu Aug 21 2025 wenyuzifang - 5.9-3 +- Apply patch to ensure reliable module loading and avoid runtime failures in security-hardened environments +- Fix segfault by nullifying freed pointers, improving stability and memory safety +- Ensure accurate UTF-8 detection and correct regex behavior across locales +- Apply patch to ensure accurate detection of terminfo variables across strict compilers * Mon Dec 09 2024 mgb01105731 - 5.9-2 - Rebuild for remove inappropriate build dependencies.