From 588586c57666c79875ee3aef95d87b916df15eca Mon Sep 17 00:00:00 2001 From: Siteshwar Vashisht Date: Mon, 10 Oct 2022 16:44:49 +0200 Subject: [PATCH] Fix an issue with nested expansions Resolves: #2133097 --- bash-5.2-nested-expansion.patch | 39 +++++++++++++++++++++++++++++++++ bash.spec | 10 ++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 bash-5.2-nested-expansion.patch diff --git a/bash-5.2-nested-expansion.patch b/bash-5.2-nested-expansion.patch new file mode 100644 index 0000000..a8d4ec1 --- /dev/null +++ b/bash-5.2-nested-expansion.patch @@ -0,0 +1,39 @@ +diff --git a/subst.c b/subst.c +--- a/subst.c ++++ b/subst.c +@@ -1803,6 +1803,9 @@ extract_heredoc_dolbrace_string (string, sindex, quoted, flags) + return (result); + } + ++#define PARAMEXPNEST_MAX 32 // for now ++static int dbstate[PARAMEXPNEST_MAX]; ++ + /* Extract a parameter expansion expression within ${ and } from STRING. + Obey the Posix.2 rules for finding the ending `}': count braces while + skipping over enclosed quoted strings and command substitutions. +@@ -1833,6 +1836,8 @@ extract_dollar_brace_string (string, sindex, quoted, flags) + if (quoted == Q_HERE_DOCUMENT && dolbrace_state == DOLBRACE_QUOTE && (flags & SX_NOALLOC) == 0) + return (extract_heredoc_dolbrace_string (string, sindex, quoted, flags)); + ++ dbstate[0] = dolbrace_state; ++ + pass_character = 0; + nesting_level = 1; + slen = strlen (string + *sindex) + *sindex; +@@ -1857,6 +1862,8 @@ extract_dollar_brace_string (string, sindex, quoted, flags) + + if (string[i] == '$' && string[i+1] == LBRACE) + { ++ if (nesting_level < PARAMEXPNEST_MAX) ++ dbstate[nesting_level] = dolbrace_state; + nesting_level++; + i += 2; + if (dolbrace_state == DOLBRACE_QUOTE || dolbrace_state == DOLBRACE_WORD) +@@ -1869,6 +1876,7 @@ extract_dollar_brace_string (string, sindex, quoted, flags) + nesting_level--; + if (nesting_level == 0) + break; ++ dolbrace_state = (nesting_level < PARAMEXPNEST_MAX) ? dbstate[nesting_level] : dbstate[0]; /* Guess using initial state */ + i++; + continue; + } diff --git a/bash.spec b/bash.spec index 799be7b..e87569e 100644 --- a/bash.spec +++ b/bash.spec @@ -6,7 +6,7 @@ Version: %{baseversion}.%{patchlevel} Name: bash Summary: The GNU Bourne Again shell -Release: 1%{?dist} +Release: 2%{?dist} License: GPLv3+ Url: https://www.gnu.org/software/bash Source0: https://ftp.gnu.org/gnu/bash/bash-%{baseversion}.tar.gz @@ -89,6 +89,10 @@ Patch127: bash-4.4-no-loadable-builtins.patch # This option is undocumented in upstream and is documented by this patch Patch128: bash-5.0-syslog-history.patch +# 2133097 - bash fails to handle nested expansions +# This patch should be removed with next rebase +Patch129: bash-5.2-nested-expansion.patch + BuildRequires: gcc BuildRequires: texinfo bison BuildRequires: ncurses-devel @@ -320,6 +324,10 @@ end %{_libdir}/pkgconfig/%{name}.pc %changelog +* Mon Oct 10 2022 Siteshwar Vashisht - 5.2.2-2 +- Fix an issue with nested expansions + Resolves: #2133097 + * Thu Oct 06 2022 Siteshwar Vashisht - 5.2.2-1 - Update to bash-5.2 patchlevel 2